<?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>readfi</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="readf.html" title="readf" /> <link rel="next" href="readk.html" title="readk" /> </head> <body> <div class="navheader"> <table width="100%" summary="Navigation header"> <tr> <th colspan="3" align="center">readfi</th> </tr> <tr> <td width="20%" align="left"><a accesskey="p" href="readf.html">Prev</a> </td> <th width="60%" align="center">Orchestra Opcodes and Operators</th> <td width="20%" align="right"> <a accesskey="n" href="readk.html">Next</a></td> </tr> </table> <hr /> </div> <div class="refentry"> <a id="readfi"></a> <div class="titlepage"></div> <a id="IndexReadfi" class="indexterm"></a> <div class="refnamediv"> <h2> <span class="refentrytitle">readfi</span> </h2> <p>readfi — Read a line of text from an external file. </p> </div> <div class="refsect1"> <a id="idm281472896303272"></a> <h2>Description</h2> <p> Read a line of text from an external file once on initialisation. </p> </div> <div class="refsect1"> <a id="idm281472896302088"></a> <h2>Syntax</h2> <pre class="synopsis">Sres, iline <span class="command"><strong>readfi</strong></span> ifilname</pre> </div> <div class="refsect1"> <a id="idm281472896241976"></a> <h2>Initialization</h2> <p> <span class="emphasis"><em>ifilname</em></span> -- an integer N denoting a file named "input.N" or a character string (in double quotes, spaces permitted) denoting the external file name. For a string, it may either be a full path name with directory specified or a simple filename. In the later case, the file is sought first in the current directory, then in SSDIR, and finally in SFDIR. </p> <p> <span class="emphasis"><em>iline</em></span> -- line number, or -1 when end of file has been reached. </p> <p> <span class="emphasis"><em>Sres</em></span> -- output of the line read from <span class="emphasis"><em>ifilname</em></span>. </p> <p> This opcode allows a line of text to be read from a named external file. There may be any number of <span class="emphasis"><em>readfi</em></span> opcodes in an instrument or orchestra but they read separately from the same or different files. </p> </div> <div class="refsect1"> <a id="idm281472896236840"></a> <h2>Examples</h2> <p> Here is an example of the readfi opcode. It uses the file <a class="ulink" href="examples/readfi.csd" target="_top"><em class="citetitle">readfi.csd</em></a>. </p> <div class="example"> <a id="idm281472896234984"></a> <p class="title"> <strong>Example 811. Example of the readfi 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="idm281472718456088"></a> <pre class="programlisting"> <span class="nt"><CsoundSynthesizer></span> <span class="nt"><CsOptions></span> -n <span class="nt"></CsOptions></span> <span class="nt"><CsInstruments></span> <span class="kd">instr</span> <span class="nf">1</span> S<span class="n">wd</span> <span class="nb">pwd</span> <span class="nb">printf_i</span> <span class="s">"Working directory is '%s'</span><span class="se">\n</span><span class="s">"</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span> S<span class="n">wd</span> <span class="nb">prints</span> <span class="s">"Reading myself =):</span><span class="se">\n</span><span class="s">"</span> <span class="nl">read</span><span class="p">:</span> S<span class="n">line</span><span class="p">,</span> i<span class="n">LineNum</span> <span class="nb">readfi</span> <span class="s">"readfi.csd"</span> <span class="nb">printf_i</span> <span class="s">"Line </span><span class="si">%d</span><span class="s">: %s"</span><span class="p">,</span> i<span class="n">LineNum</span><span class="p">,</span> i<span class="n">LineNum</span><span class="p">,</span> S<span class="n">line</span> <span class="k">if</span> i<span class="n">LineNum</span> <span class="o">!=</span> <span class="o">-</span><span class="mi">1</span> <span class="k">igoto</span> <span class="nl">read</span> <span class="kd">endin</span> <span class="nt"></CsInstruments></span> <span class="nt"><CsScore></span> <span class="nb">i</span><span class="mi">1</span> <span class="mi">0</span> <span class="mf">0.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" /> </p> </div> <div class="refsect1"> <a id="idm281472896230696"></a> <h2>See Also</h2> <p> <a class="link" href="readf.html" title="readf"><em class="citetitle">readf</em></a>. </p> </div> <div class="refsect1"> <a id="idm281472896228616"></a> <h2>Credits</h2> <p>John ffitch and Joachim Heintz</p> <p>2012; new in 5.17.12</p> </div> </div> <div class="navfooter"> <hr /> <table width="100%" summary="Navigation footer"> <tr> <td width="40%" align="left"><a accesskey="p" href="readf.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="readk.html">Next</a></td> </tr> <tr> <td width="40%" align="left" valign="top">readf </td> <td width="20%" align="center"> <a accesskey="h" href="index.html">Home</a> </td> <td width="40%" align="right" valign="top"> readk</td> </tr> </table> </div> </body> </html>