summaryrefslogtreecommitdiff
path: root/opcodes/sprintf.xml
blob: 331c5029f117fd5ae29d67c3684102fd710f059c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
<refentry id="sprintf">
<indexterm id="Indexsprintf"><primary>sprintf</primary></indexterm>
  <refentryinfo><title>Strings:Manipulation</title></refentryinfo>
  <refmeta>
    <refentrytitle>sprintf</refentrytitle>
  </refmeta>

  <refnamediv>
    <refname>sprintf</refname>
    <refpurpose>
      printf-style formatted output to a string variable.
    </refpurpose>
  </refnamediv>

  <refsect1>
    <title>Description</title>
    <para>
      <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.
    </para>
  </refsect1>

  <refsect1>
    <title>Syntax</title>
    <synopsis>Sdst <command>sprintf</command> Sfmt, xarg1[, xarg2[, ... ]]</synopsis>
  </refsect1>

  <refsect1>
    <title>Initialization</title>
    <para>
      <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:
      <itemizedlist>
        <listitem>
	  <para>d, i, o, u, x, X, e, E, f, F, g, G, c, s</para>
	</listitem>
      </itemizedlist>
    </para>

    <para>
      <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.
    </para>
  </refsect1>

  <refsect1>
    <title>Performance</title>
    <para>
      <emphasis>Sdst</emphasis> -- output string variable
    </para>
  </refsect1>

  <refsect1>
    <title>Example</title>
    <programlisting>
Sname   <emphasis role="opc">sprintf</emphasis> "soundin-%04d.wav", ifileno
Smsg    <emphasis role="opc">sprintf</emphasis> "The file name is: '%s'", Sname
        <emphasis role="opc">puts</emphasis>    Smsg, 1
asig    <emphasis role="opc">soundin</emphasis> Sname</programlisting>
  </refsect1>

  <refsect1>
    <title>See Also</title>
    <para>
      <link linkend="sprintfk"><citetitle>sprintfk</citetitle></link>
    </para>
  </refsect1>

  <refsect1>
    <title>Credits</title>
    <para>
      <simplelist>
        <member>Author: Istvan Varga</member>
        <member>2005</member>
      </simplelist>
    </para>
  </refsect1>
</refentry>