sprintf
Prev | Orchestra Opcodes and Operators | Next

## sprintf

sprintf — printf-style formatted output to a string variable

## Description

sprintf and sprintfk write printf-style formatted output to a string variable, similarly to the C function sprintf(). sprintf runs at i-time only, while sprintfk runs both at initialization and performance time.

## Syntax

    Sdst sprintf Sfmt, xarg1[, xarg2[, ... ]]

    Sdst sprintfk Sfmt, xarg1[, xarg2[, ... ]]

## Initialization

Sfmt -- 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:

- d, i, o, u, x, X, e, E, f, F, g, G, c, s

xarg1, xarg2, ... -- input arguments (max. 30) for format, should be i-rate for all conversion specifiers except %s, which requires a string argument. sprintfk also allows k-rate number arguments, but these should still be valid at init time as well (unless sprintfk is skipped with igoto). Integer formats like %d round the input values to the nearest integer.

## Performance

Sdst -- output string variable

## Example

    Sname   sprintf "soundin-%04d.wav", ifileno
    Smsg    sprintf "The file name is: '%s'", Sname
    	puts Smsg, 1
    asig	soundin Sname

## Credits

Author: Istvan Varga
2005

Prev | Up | Next
spsend | Home | sqrt