| 1 | |
| 2 | <refentry id="evalstr"> |
| 3 | <indexterm id="Indexevalstr"><primary>evalstr</primary></indexterm> |
| 4 | <refentryinfo><title>Instrument Control:Compilation</title></refentryinfo> |
| 5 | <refmeta> |
| 6 | <refentrytitle>evalstr</refentrytitle> |
| 7 | </refmeta> |
| 8 | |
| 9 | <refnamediv> |
| 10 | <refname>evalstr</refname> |
| 11 | <refpurpose> |
| 12 | Evalstrs evaluates a string containing Csound code, returning a value. |
| 13 | </refpurpose> |
| 14 | </refnamediv> |
| 15 | |
| 16 | <refsect1> |
| 17 | <title>Description</title> |
| 18 | <para> |
| 19 | Evalstr compiles and runs Csound code and returns a value from the global space (instr 0). This opcode can be |
| 20 | also used to compile new instruments (as compilestr). |
| 21 | </para> |
| 22 | </refsect1> |
| 23 | |
| 24 | <refsect1> |
| 25 | <title>Syntax</title> |
| 26 | <synopsis>ires <command>evalstr</command> Scode </synopsis> |
| 27 | <synopsis>kres <command>evalstr</command> Scode, ktrig </synopsis> |
| 28 | </refsect1> |
| 29 | |
| 30 | <refsect1> |
| 31 | <title>Initialization</title> |
| 32 | <para> |
| 33 | <emphasis><quote>Scode</quote></emphasis> -- a string to be compiled and evaluated. |
| 34 | </para> |
| 35 | |
| 36 | </refsect1> |
| 37 | <refsect1> |
| 38 | <title>Performance</title> |
| 39 | <para> |
| 40 | <emphasis><quote>ktrig</quote></emphasis> -- triggers the compilation/evaluation if non-zero. |
| 41 | </para> |
| 42 | |
| 43 | </refsect1> |
| 44 | |
| 45 | |
| 46 | <refsect1> |
| 47 | <title>Examples</title> |
| 48 | <para> |
| 49 | Here is an example of the evalstr opcode in conjunction with return: |
| 50 | <example> |
| 51 | <para> |
| 52 | <programlisting> |
| 53 | ival <emphasis role="op">evalstr</emphasis> "return 2 + 2" |
| 54 | <emphasis role="op">print</emphasis> ival |
| 55 | </programlisting> |
| 56 | </para> |
| 57 | </example> |
| 58 | </para> |
| 59 | |
| 60 | <para> |
| 61 | Here is a complete example of the evalstr opcode. It uses the file <ulink url="examples/evalstr.csd"><citetitle>evalstr.csd</citetitle></ulink>. |
| 62 | <example> |
| 63 | <title>Example of the evalstr opcode.</title> |
| 64 | <xi:include href="examples-xml/evalstr.csd.xml" xmlns:xi="http://www.w3.org/2001/XInclude"/> |
| 65 | </example> |
| 66 | </para> |
| 67 | </refsect1> |
| 68 | |
| 69 | <refsect1> |
| 70 | <title>See Also</title> |
| 71 | <para><link linkend="stringmanipulate"><citetitle></citetitle>String Manipulation Opcodes</link></para> |
| 72 | </refsect1> |
| 73 | |
| 74 | <refsect1> |
| 75 | <title>Credits</title> |
| 76 | <para>Author: &namevictor;, 2013 </para> |
| 77 | </refsect1> |
| 78 | </refentry> |