Csound Csound-dev Csound-tekno Search About

[Cs-dev] New Csound5 opcodes: sprintf, puts

Date2005-04-27 18:55
FromIstvan Varga
Subject[Cs-dev] New Csound5 opcodes: sprintf, puts
Sr      sprintf     Sformat, xarg1[, xarg2[, ... xarg30]]
Sr      sprintfk    Sformat, xarg1[, xarg2[, ... xarg30]]

DESCRIPTION
-----------

sprintf and sprintfk write 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.

INITIALIZATION
--------------

Sr - output string variable

Sformat - 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 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.

PERFORMANCE
-----------

Sr - output string variable (sprintfk)

Sformat - format string for sprintfk

xarg1, xarg2, ... - input arguments for format, sprintfk allows the
     use of k-rate variables, however, these should be valid at i-time
     as well

----------------------------------------------------------------------

         puts Sstr, ktrig[, inonl]

DESCRIPTION
-----------

puts prints a string at initialization time, and also at performance
time whenever the k-rate trigger signal is positive and is different
from the previous value. A trailing newline character is printed unless
the optional i-time argument is non-zero.

----------------------------------------------------------------------

EXAMPLE
-------

iPI     =  4 * taninv(1)
SPI     strcpy "\033[1mPI\033[m"
S1      sprintf "%s = %f, int(%s) = %d\n", SPI, iPI, SPI, iPI
         puts S1, 1, 1



-------------------------------------------------------
SF.Net email is sponsored by: Tell us your software development plans!
Take this survey and enter to win a one-year sub to SourceForge.net
Plus IDC's 2005 look-ahead and a copy of this survey
Click here to start!  http://www.idcswdc.com/cgi-bin/survey?id=105hix
_______________________________________________
Csound-devel mailing list
Csound-devel@lists.sourceforge.net