Csound Csound-dev Csound-tekno Search About

[Cs-dev] String variables added to Csound5

Date2005-04-26 18:23
FromIstvan Varga
Subject[Cs-dev] String variables added to Csound5
A string variable is defined by using 'S' as the type letter, and can
be either global (gSname) or local (Sname). Operations on string
variables are performed at i-time, however, some string opcodes will
also run at performance time.

By default, the maximum allowed length of string variables is 255
characters, however, this limit can be changed with the -+max_str_len
command line option; for example, -+max_str_len=1000 will set the
maximum length to 999 characters.
Note: the length of string constants is not limited.

Currently, the following opcodes can be used for manipulating strings,
but more should be available soon. Existing opcodes that expect a quoted
string constant as input argument should also work with string variables.

     strset  indx, Sstr

set string value in strset table at the specified index to Sstr.
The opcode can be used both in the orchestra header and in instruments,
and runs at i-time, dynamically extending the table if needed.

Sr  strget  indx

copies value from strset table at the specified index to Sr, or, if
the index is a string p-field from the score, then that string is
copied. If no string is defined for indx, Sr is set to empty string.

Sr  strcpy  Sstr

copies Sstr to Sr. Using the same variable for input and output is
allowed (the opcode has no effect in this case).

Sr  strcpyk Sstr

same as strcpy, but runs both at initialization and performance time.

Sr  strcat  Sstr1, Sstr2

concatenates strings, by appending Sstr2 to Sstr1, and leaves the result
in Sr. It is allowed for Sr to be the same variable as Sstr1 or Sstr2.

Sr  strcatk Sstr1, Sstr2

same as strcat, but runs both at initialization and performance time.

ir  strcmp  Sstr1, Sstr2

compares two strings, and sets ir to -1, 0, or 1 if Sstr1 is less than,
equal to, or greater than Sstr2, respectively.

kr  strcmpk Sstr1, Sstr2

same as strcmp, but runs both at initialization and performance time.

Example:

S1  strcpy "foo"
S2  strcpy "bar.wav"
S3  strcat S1, S2
a1  diskin2 S3, 1  ; reads foobar.wav



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

Date2005-04-26 19:28
FromAnthony Kozar
SubjectRe: [Cs-dev] String variables added to Csound5
Why not reallocate space as needed ?  I don't think that the user should
have to worry about string lengths.

Anthony

On 4/26/05 1:23 PM, Istvan Varga  etched in stone:

> A string variable is defined by using 'S' as the type letter, and can
> By default, the maximum allowed length of string variables is 255
> characters, however, this limit can be changed with the -+max_str_len
> command line option; for example, -+max_str_len=1000 will set the
> maximum length to 999 characters.
> Note: the length of string constants is not limited.



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

Date2005-04-26 21:26
FromIstvan Varga
SubjectRe: [Cs-dev] String variables added to Csound5
Anthony Kozar wrote:

> Why not reallocate space as needed ?  I don't think that the user should
> have to worry about string lengths.

This is not really easy with the model used in Csound to allocate
variables and pass pointers to variables to opcodes.


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