<?xml version="1.0" encoding="UTF-8" standalone="no"?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <title>=</title> <link rel="stylesheet" type="text/css" href="csound.css" /> <link rel="stylesheet" type="text/css" href="syntax-highlighting.css" /> <meta name="generator" content="DocBook XSL Stylesheets Vsnapshot" /> <link rel="home" href="index.html" title="The Canonical Csound Reference Manual" /> <link rel="up" href="OpcodesTop.html" title="Orchestra Opcodes and Operators" /> <link rel="prev" href="divides.html" title="/" /> <link rel="next" href="plusbecomes.html" title="+=" /> </head> <body> <div class="navheader"> <table width="100%" summary="Navigation header"> <tr> <th colspan="3" align="center">=</th> </tr> <tr> <td width="20%" align="left"><a accesskey="p" href="divides.html">Prev</a> </td> <th width="60%" align="center">Orchestra Opcodes and Operators</th> <td width="20%" align="right"> <a accesskey="n" href="plusbecomes.html">Next</a></td> </tr> </table> <hr /> </div> <div class="refentry"> <a id="assign"></a> <div class="titlepage"></div> <a id="IndexAssign" class="indexterm"></a> <div class="refnamediv"> <h2> <span class="refentrytitle">=</span> </h2> <p>= — Performs a simple assignment. </p> </div> <div class="refsect1"> <a id="idm281472953030296"></a> <h2>Syntax</h2> <pre class="synopsis">ares <span class="command"><strong>=</strong></span> xarg</pre> <pre class="synopsis">ires <span class="command"><strong>=</strong></span> iarg</pre> <pre class="synopsis">kres <span class="command"><strong>=</strong></span> karg</pre> <pre class="synopsis">ires, ... <span class="command"><strong>=</strong></span> iarg, ...</pre> <pre class="synopsis">kres, ... <span class="command"><strong>=</strong></span> karg, ...</pre> <pre class="synopsis">table [ kval] <span class="command"><strong>=</strong></span> karg</pre> </div> <div class="refsect1"> <a id="idm281472952981224"></a> <h2>Description</h2> <p> Performs a simple assignment. </p> </div> <div class="refsect1"> <a id="idm281472952979880"></a> <h2>Initialization</h2> <p> <span class="emphasis"><em>=</em></span> (simple assignment) - Put the value of the expression <span class="emphasis"><em>iarg</em></span> (<span class="emphasis"><em>karg, xarg</em></span>) into the named result. This provides a means of saving an evaluated result for later use. </p> <p> From version 5.13 onwards the i- and k-rate versions of assignment can take a number of outputs, and an equal or less number of inputs. If there are less the last value is repeated as necessary. </p> <p> From version 5.14 values can be assigned to elements of a vector with the square bracket form. </p> </div> <div class="refsect1"> <a id="idm281472952975800"></a> <h2>Examples</h2> <p> Here is an example of the assign opcode. It uses the file <a class="ulink" href="examples/assign.csd" target="_top"><em class="citetitle">assign.csd</em></a>. </p> <div class="example"> <a id="idm281472952974024"></a> <p class="title"> <strong>Example 31. Example of the assign opcode.</strong> </p> <div class="example-contents"> <p>See the sections <a class="link" href="UsingRealTime.html" title="Real-Time Audio"><em class="citetitle">Real-time Audio</em></a> and <a class="link" href="CommandFlags.html" title="Csound command line"><em class="citetitle">Command Line Flags</em></a> for more information on using command line flags.</p> <div class="refsect1"> <a id="idm281472788972616"></a> <pre class="programlisting"> <span class="nt"><CsoundSynthesizer></span> <span class="nt"><CsOptions></span> <span class="c1">; Select audio/midi flags here according to platform</span> -odac <span class="c1">;;;RT audio out</span> <span class="c1">;-iadc ;;;uncomment -iadc if RT audio input is needed too</span> <span class="c1">; For Non-realtime ouput leave only the line below:</span> <span class="c1">; -o assign.wav -W ;;; for file output any platform</span> <span class="nt"></CsOptions></span> <span class="nt"><CsInstruments></span> <span class="vg">sr</span> <span class="o">=</span> <span class="mi">44100</span> <span class="vg">ksmps</span> <span class="o">=</span> <span class="mi">32</span> <span class="vg">nchnls</span> <span class="o">=</span> <span class="mi">2</span> <span class="kd">instr</span> <span class="nf">1</span> <span class="c1">; Assign a value to the variable i1.</span> i<span class="n">1</span> <span class="o">=</span> <span class="mi">1234</span> <span class="c1">; Print the value of the i1 variable.</span> <span class="nb">print</span> i<span class="n">1</span> <span class="kd">endin</span> <span class="nt"></CsInstruments></span> <span class="nt"><CsScore></span> <span class="c1">; Play Instrument #1 for one second.</span> <span class="nb">i</span> <span class="mi">1</span> <span class="mi">0</span> <span class="mi">1</span> <span class="nb">e</span> <span class="nt"></CsScore></span> <span class="nt"></CsoundSynthesizer></span> </pre> </div> </div> </div> <p><br class="example-break" /> Its output should include a line like this: </p> <pre class="screen"> instr 1: i1 = 1234.000</pre> <p> </p> </div> <div class="refsect1"> <a id="idm281472952969048"></a> <h2>See Also</h2> <p> <a class="link" href="divz.html" title="divz"><em class="citetitle">divz</em></a>, <a class="link" href="init.html" title="init"><em class="citetitle">init</em></a>, <a class="link" href="passign.html" title="passign"><em class="citetitle">passign</em></a>, <a class="link" href="tival.html" title="tival"><em class="citetitle">tival</em></a> </p> </div> <div class="refsect1"> <a id="idm281472952964024"></a> <h2>Credits</h2> <p>Example written by Kevin Conder.</p> <p> The extension to multiple values is by </p> <table border="0" summary="Simple list" class="simplelist"> <tr> <td>Author: John ffitch</td> </tr> <tr> <td>University of Bath, and Codemist Ltd.</td> </tr> <tr> <td>Bath, UK</td> </tr> <tr> <td>February 2010</td> </tr> </table> <p> </p> <p>New in version 5.13</p> <p> </p> </div> </div> <div class="navfooter"> <hr /> <table width="100%" summary="Navigation footer"> <tr> <td width="40%" align="left"><a accesskey="p" href="divides.html">Prev</a> </td> <td width="20%" align="center"> <a accesskey="u" href="OpcodesTop.html">Up</a> </td> <td width="40%" align="right"> <a accesskey="n" href="plusbecomes.html">Next</a></td> </tr> <tr> <td width="40%" align="left" valign="top">/ </td> <td width="20%" align="center"> <a accesskey="h" href="index.html">Home</a> </td> <td width="40%" align="right" valign="top"> +=</td> </tr> </table> </div> </body> </html>