| 1 | |
| 2 | <refentry id="opor"> |
| 3 | <indexterm id="IndexVerbarVerbar"><primary>||</primary></indexterm> |
| 4 | <refentryinfo><title>Mathematical Operations:Arithmetic and Logic Operations</title></refentryinfo> |
| 5 | <refmeta> |
| 6 | <refentrytitle>||</refentrytitle> |
| 7 | </refmeta> |
| 8 | |
| 9 | |
| 10 | |
| 11 | <refnamediv> |
| 12 | <refname>||</refname> |
| 13 | |
| 14 | <refpurpose> |
| 15 | Logical OR operator. |
| 16 | </refpurpose> |
| 17 | </refnamediv> |
| 18 | |
| 19 | <refsect1> |
| 20 | <title>Description</title> |
| 21 | <para> |
| 22 | Arithmetic operators perform operations of change-sign (negate), don't-change-sign, logical AND logical OR, add, subtract, multiply and divide. Note that a value or an expression may fall between two of these operators, either of which could take it as its left or right argument, as in |
| 23 | <literallayout> |
| 24 | a + b * c. |
| 25 | </literallayout> |
| 26 | </para> |
| 27 | |
| 28 | <para> |
| 29 | In such cases three rules apply: |
| 30 | </para> |
| 31 | |
| 32 | <para> |
| 33 | 1. * and <emphasis>/</emphasis> bind to their neighbors more strongly than + and −. Thus the above expression is taken as |
| 34 | <literallayout> |
| 35 | a + (b * c) |
| 36 | </literallayout> |
| 37 | with * taking b and c and then + taking a and b * c. |
| 38 | </para> |
| 39 | |
| 40 | <para> |
| 41 | 2. <emphasis>+</emphasis> and <emphasis>−</emphasis> bind more strongly than &&, which in turn is stronger than ||: |
| 42 | <literallayout> |
| 43 | a && b - c || d |
| 44 | </literallayout> |
| 45 | is taken as |
| 46 | <literallayout> |
| 47 | (a && (b - c)) || d |
| 48 | </literallayout> |
| 49 | </para> |
| 50 | |
| 51 | <para> |
| 52 | 3. When both operators bind equally strongly, the operations are done left to right: |
| 53 | <literallayout> |
| 54 | a - b - c |
| 55 | </literallayout> |
| 56 | is taken as |
| 57 | <literallayout> |
| 58 | (a - b) - c |
| 59 | </literallayout> |
| 60 | </para> |
| 61 | |
| 62 | <para> |
| 63 | Parentheses may be used as above to force particular groupings. |
| 64 | </para> |
| 65 | </refsect1> |
| 66 | |
| 67 | <refsect1> |
| 68 | <title>Syntax</title> |
| 69 | <synopsis>a <command>||</command> b (logical OR; not audio-rate)</synopsis> |
| 70 | |
| 71 | <para> |
| 72 | where the arguments <emphasis>a</emphasis> and <emphasis>b</emphasis> may be further expressions. |
| 73 | </para> |
| 74 | </refsect1> |
| 75 | |
| 76 | <refsect1> |
| 77 | <title>Examples</title> |
| 78 | <para> |
| 79 | Here is an example of the | operator. It uses the file <ulink url="examples/logicOR.csd"><citetitle>logicOR.csd</citetitle></ulink>. |
| 80 | <example> |
| 81 | <title>Example of the | operator.</title> |
| 82 | <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> |
| 83 | <xi:include href="examples-xml/logicOR.csd.xml" xmlns:xi="http://www.w3.org/2001/XInclude"/> |
| 84 | </example> |
| 85 | |
| 86 | Its output should include a line like these: |
| 87 | <screen> |
| 88 | Value:127 ChanNo:11 CtrlNo:62 |
| 89 | Value:127 ChanNo:11 CtrlNo:60 |
| 90 | Value:127 ChanNo:11 CtrlNo:60 |
| 91 | Value:127 ChanNo:11 CtrlNo:60 |
| 92 | Value:127 ChanNo:11 CtrlNo:60 |
| 93 | .... |
| 94 | Value:0 ChanNo:11 CtrlNo:62 |
| 95 | Value:0 ChanNo:11 CtrlNo:62 |
| 96 | Value:0 ChanNo:11 CtrlNo:62 |
| 97 | Value:0 ChanNo:11 CtrlNo:62 |
| 98 | .... |
| 99 | Value:77 ChanNo:11 CtrlNo:23 |
| 100 | Value:77 ChanNo:11 CtrlNo:23 |
| 101 | Value:76 ChanNo:11 CtrlNo:23 |
| 102 | Value:76 ChanNo:11 CtrlNo:23 |
| 103 | ....</screen> |
| 104 | </para> |
| 105 | </refsect1> |
| 106 | |
| 107 | <refsect1> |
| 108 | <title>See also</title> |
| 109 | <para><link linkend="MathArtLogic"><citetitle>Arithmetic and Logic Operations</citetitle></link></para> |
| 110 | </refsect1> |
| 111 | |
| 112 | </refentry> |