| 1 | |
| 2 | <refentry id="sprintf"> |
| 3 | <indexterm id="Indexsprintf"><primary>sprintf</primary></indexterm> |
| 4 | <refentryinfo><title>Strings:Manipulation</title></refentryinfo> |
| 5 | <refmeta> |
| 6 | <refentrytitle>sprintf</refentrytitle> |
| 7 | </refmeta> |
| 8 | |
| 9 | <refnamediv> |
| 10 | <refname>sprintf</refname> |
| 11 | <refpurpose> |
| 12 | printf-style formatted output to a string variable. |
| 13 | </refpurpose> |
| 14 | </refnamediv> |
| 15 | |
| 16 | <refsect1> |
| 17 | <title>Description</title> |
| 18 | <para> |
| 19 | <emphasis>sprintf</emphasis> write printf-style formatted output to a string variable, similarly to the C function sprintf(). <emphasis>sprintf</emphasis> runs at i-time only. |
| 20 | </para> |
| 21 | </refsect1> |
| 22 | |
| 23 | <refsect1> |
| 24 | <title>Syntax</title> |
| 25 | <synopsis>Sdst <command>sprintf</command> Sfmt, xarg1[, xarg2[, ... ]]</synopsis> |
| 26 | </refsect1> |
| 27 | |
| 28 | <refsect1> |
| 29 | <title>Initialization</title> |
| 30 | <para> |
| 31 | <emphasis>Sfmt</emphasis> -- format string, has the same format as in printf() and other similar C functions, except length modifiers (l, ll, h, etc.) are not supported. The following conversion specifiers are allowed: |
| 32 | <itemizedlist> |
| 33 | <listitem> |
| 34 | <para>d, i, o, u, x, X, e, E, f, F, g, G, c, s</para> |
| 35 | </listitem> |
| 36 | </itemizedlist> |
| 37 | </para> |
| 38 | |
| 39 | <para> |
| 40 | <emphasis>xarg1, xarg2, ...</emphasis> -- input arguments (max. 30) for format, should be i-rate for all conversion specifiers except %s, which requires a string argument. Integer formats like %d round the input values to the nearest integer. |
| 41 | </para> |
| 42 | </refsect1> |
| 43 | |
| 44 | <refsect1> |
| 45 | <title>Performance</title> |
| 46 | <para> |
| 47 | <emphasis>Sdst</emphasis> -- output string variable |
| 48 | </para> |
| 49 | </refsect1> |
| 50 | |
| 51 | <refsect1> |
| 52 | <title>Examples</title> |
| 53 | <para> |
| 54 | Here is an example of the sprintf opcode. It uses the file <ulink url="examples/sprintf.csd"><citetitle>sprintf.csd</citetitle></ulink>. |
| 55 | <example> |
| 56 | <title>Example of the sprintf opcode.</title> |
| 57 | <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> |
| 58 | <xi:include href="examples-xml/sprintf.csd.xml" xmlns:xi="http://www.w3.org/2001/XInclude"/> |
| 59 | </example> |
| 60 | Its output should include lines like this: |
| 61 | <screen> |
| 62 | The file name is: 'impuls20.aiff' |
| 63 | soundin: opened 'impuls20.aiff' |
| 64 | </screen> |
| 65 | </para> |
| 66 | </refsect1> |
| 67 | |
| 68 | <refsect1> |
| 69 | <title>See Also</title> |
| 70 | <para><link linkend="stringmanipulate"><citetitle></citetitle>String Manipulation Opcodes</link></para> |
| 71 | </refsect1> |
| 72 | |
| 73 | <refsect1> |
| 74 | <title>Credits</title> |
| 75 | <para> |
| 76 | <simplelist> |
| 77 | <member>Author: Istvan Varga</member> |
| 78 | <member>2005</member> |
| 79 | </simplelist> |
| 80 | </para> |
| 81 | </refsect1> |
| 82 | </refentry> |