Programmer Guide/Command Reference/FORMAT: Difference between revisions
From STX Wiki
Jump to navigationJump to search
m (1 revision: Initial import) |
No edit summary |
||
Line 1: | Line 1: | ||
{{DISPLAYTITLE:{{SUBPAGENAME}}}} | {{DISPLAYTITLE:{{SUBPAGENAME}}}} | ||
<var>var</var> := FORMAT formatstring arg1 [arg2 ...] | |||
<code> | <code>format</code> formats its arguments, interpreting the first argument as a format string (almost, but not quite unlike the <code>print. S_TOOLS-STx formats are described in [[Programmer Guide/Format Strings and Rules]]. | ||
#srateHz := 44100 | |||
#SRSTR := FORMAT '%.1f kHz' '$#srateHz/1000' | |||
Here, the variable <code>#SRSTR</code> is assigned the value '<code>44.1 kHz</code>'. | |||
Note that, unlike C, the first argument <code>arg1</code> is ''mandatory'' with the STx <coce>format</code> command: | |||
#str := format 'How much wood would a wood chuck chuck?' 'dummy' | |||
Here, dummy argument (in our case, the string constant <code>'dummy'</code> is mandatory, although it will not influence the result of the string "How much wood would a wood chuck chuck?" being assigned to the variable <var>#str</var>. | |||
# | |||
Revision as of 12:12, 31 March 2011
var := FORMAT formatstring arg1 [arg2 ...]
format
formats its arguments, interpreting the first argument as a format string (almost, but not quite unlike the print. S_TOOLS-STx formats are described in Programmer Guide/Format Strings and Rules.
#srateHz := 44100
#SRSTR := FORMAT '%.1f kHz' '$#srateHz/1000'
Here, the variable #SRSTR
is assigned the value '44.1 kHz
'.
Note that, unlike C, the first argument
command:
arg1
is mandatory with the STx <coce>format
#str := format 'How much wood would a wood chuck chuck?' 'dummy'
Here, dummy argument (in our case, the string constant 'dummy'
is mandatory, although it will not influence the result of the string "How much wood would a wood chuck chuck?" being assigned to the variable #str.