summaryrefslogtreecommitdiff
path: root/opcodes/equals.xml
blob: 96729d161d5a6fbdf5fde02e0e891738c8056d1d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
<refentry id="equals">
<indexterm id="IndexEqualsColon"><primary>:</primary></indexterm>

<indexterm id="IndexEqualsQuestion"><primary>?</primary></indexterm>

<indexterm id="IndexEqualsExpression"><primary>conditional expressions</primary></indexterm>

<indexterm id="IndexEquals"><primary>==</primary></indexterm>
  <refentryinfo><title>Instrument Control:Conditional Values</title></refentryinfo>
  <refmeta>
    <refentrytitle>==</refentrytitle>
  </refmeta>


 
  <refnamediv>
    <refname>==</refname>

    <refpurpose>
      Compares two values for equality.
                            </refpurpose>
  </refnamediv>
 
  <refsect1>
    <title>Description</title>
    <para>
      Compares two values for equality.
    </para>
  </refsect1>

  <refsect1>
    <title>Syntax</title>
    <synopsis>(a <command>==</command> b <command>?</command> v1 <command>:</command> v2)</synopsis>

    <para>
      where <emphasis>a</emphasis>, <emphasis>b</emphasis>, <emphasis>v1</emphasis> and <emphasis>v2</emphasis> may be expressions, but <emphasis>a</emphasis>, <emphasis>b</emphasis> not audio-rate.
    </para>
  </refsect1>

  <refsect1>
    <title>Performance</title>
    <para>
      In the above conditional, <emphasis>a</emphasis> and <emphasis>b</emphasis> are first compared. If the indicated relation is true (<emphasis>a</emphasis> is equal to <emphasis>b</emphasis>), then the conditional expression has the value of <emphasis>v1</emphasis>; if the relation is false, the expression has the value of <emphasis>v2</emphasis>. (For convenience, a sole &quot;<emphasis>=</emphasis>&quot; will function as &quot;<emphasis>= =</emphasis>&quot;.)
    </para>

    <para>
      NB.: If <emphasis>v1</emphasis> or <emphasis>v2</emphasis> are expressions, these will be evaluated before the conditional is determined.
    </para>

    <para>
      In terms of binding strength, all conditional operators (i.e. the relational operators (<emphasis>&lt;</emphasis>, etc.), and <emphasis>?</emphasis>, and <emphasis>:</emphasis> ) are weaker than the arithmetic and logical operators (<emphasis>+</emphasis>, <emphasis>-</emphasis>, <emphasis>*</emphasis>, <emphasis>/</emphasis>, <emphasis>&amp;&amp;</emphasis> and <emphasis>||</emphasis>).
    </para>

    <para>
      These are <emphasis>operators</emphasis> not <emphasis>opcodes</emphasis>. Therefore, they can be used within orchestra statements, but do not form complete statements themselves.
    </para>
  </refsect1>
 
  <refsect1>
    <title>Examples</title>
    <para>
      Here is an example of the == operator. It uses the file <ulink url="examples/equals.csd"><citetitle>equals.csd</citetitle></ulink>.

      <example>
        <title>Example of the == operator.</title>

        

        <para>See the sections <link linkend="UsingRealTime"><citetitle>Real-time Audio</citetitle></link> and <link linkend="CommandFlags"><citetitle>Command Line Flags</citetitle></link> for more information on using command line flags.</para>
          <xi:include href="examples-xml/equals.csd.xml" xmlns:xi="http://www.w3.org/2001/XInclude"/>
      </example>

      Its output should include lines like this:
      <screen>
k1 = 2.000000, k2 = 0.000000
k1 = 3.000000, k2 = 1.000000
k1 = 4.000000, k2 = 0.000000</screen>
    </para>
  </refsect1>
 
  <refsect1>
    <title>See Also</title>
    <para>
      <link linkend="greaterequal"><citetitle>&gt;=</citetitle></link>, 
      <link linkend="greaterthan"><citetitle>&gt;</citetitle></link>, 
      <link linkend="lessequal"><citetitle>&lt;=</citetitle></link>, 
      <link linkend="lessthan"><citetitle>&lt;</citetitle></link>, 
      <link linkend="notequal"><citetitle>!=</citetitle></link>
    </para>
  </refsect1>

  <refsect1>
    <title>Credits</title>
    <para>Example written by &namekevin;.</para>
  </refsect1>
</refentry>