Csound Csound-dev Csound-tekno Search About

how to initialize and print a string variable in Csound

Date2017-03-08 22:03
FromRichard
Subjecthow to initialize and print a string variable in Csound
This sounds like too simple to ask, but how do I do this?

if I do in instr 0:

gSfilepath    = "../samples/4notesMono.wav"  ; is this the correct way 
to initialize a string variable?

and then try to print it like:

  prints "%s", gSfilepath

I get the following error:

error:  Unable to find opcode entry for 'prints' with matching argument 
types:
Found: (null) prints SS

Richard

Csound mailing list
Csound@listserv.heanet.ie
https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
Send bugs reports to
        https://github.com/csound/csound/issues
Discussions of bugs and features can be posted here

Date2017-03-08 22:08
FromVictor Lazzarini
SubjectRe: how to initialize and print a string variable in Csound
prints gSfilepath  

or

printf_i “%s”, 1, gSfilepath


========================
Prof. Victor Lazzarini
Dean of Arts, Celtic Studies, and Philosophy,
Maynooth University,
Maynooth, Co Kildare, Ireland
Tel: 00 353 7086936
Fax: 00 353 1 7086952 

> On 8 Mar 2017, at 22:03, Richard  wrote:
> 
> This sounds like too simple to ask, but how do I do this?
> 
> if I do in instr 0:
> 
> gSfilepath    = "../samples/4notesMono.wav"  ; is this the correct way to initialize a string variable?
> 
> and then try to print it like:
> 
> prints "%s", gSfilepath
> 
> I get the following error:
> 
> error:  Unable to find opcode entry for 'prints' with matching argument types:
> Found: (null) prints SS
> 
> Richard
> 
> Csound mailing list
> Csound@listserv.heanet.ie
> https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
> Send bugs reports to
>       https://github.com/csound/csound/issues
> Discussions of bugs and features can be posted here


Csound mailing list
Csound@listserv.heanet.ie
https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
Send bugs reports to
        https://github.com/csound/csound/issues
Discussions of bugs and features can be posted here

Date2017-03-08 22:20
FromRichard
SubjectRe: how to initialize and print a string variable in Csound
ok, seems to work


On 08/03/17 23:08, Victor Lazzarini wrote:
> prints gSfilepath
>
> or
>
> printf_i “%s”, 1, gSfilepath
>
>
> ========================
> Prof. Victor Lazzarini
> Dean of Arts, Celtic Studies, and Philosophy,
> Maynooth University,
> Maynooth, Co Kildare, Ireland
> Tel: 00 353 7086936
> Fax: 00 353 1 7086952
>
>> On 8 Mar 2017, at 22:03, Richard  wrote:
>>
>> This sounds like too simple to ask, but how do I do this?
>>
>> if I do in instr 0:
>>
>> gSfilepath    = "../samples/4notesMono.wav"  ; is this the correct way to initialize a string variable?
>>
>> and then try to print it like:
>>
>> prints "%s", gSfilepath
>>
>> I get the following error:
>>
>> error:  Unable to find opcode entry for 'prints' with matching argument types:
>> Found: (null) prints SS
>>
>> Richard
>>
>> Csound mailing list
>> Csound@listserv.heanet.ie
>> https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
>> Send bugs reports to
>>        https://github.com/csound/csound/issues
>> Discussions of bugs and features can be posted here
>
> Csound mailing list
> Csound@listserv.heanet.ie
> https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
> Send bugs reports to
>          https://github.com/csound/csound/issues
> Discussions of bugs and features can be posted here

Csound mailing list
Csound@listserv.heanet.ie
https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
Send bugs reports to
        https://github.com/csound/csound/issues
Discussions of bugs and features can be posted here

Date2017-03-08 22:44
FromRichard
SubjectRe: how to initialize and print a string variable in Csound
hmm, I still have a problem. gSfilepath is a global variable, as the 
name implies, so I initialize it in instr 0 as

gSfilepath init ""

Then later in some instrument, I assign the real string:

gSfilepath = "xxxxx"

but then the prints after that prints nothing...

The printf_i also complains:

  printf_i “filepath: %s”, 1, gSfilepath

gives:

Error: character ?(e2)

error: syntax error, unexpected ERROR_TOKEN, expecting NEWLINE or ','  
(token "?") from file reversalCab2.csd (1)
  line 158:
 >>> printf_i ? <<<
Parsing failed due to invalid input!


On 08/03/17 23:08, Victor Lazzarini wrote:
> prints gSfilepath
>
> or
>
> printf_i “%s”, 1, gSfilepath
>
>
> ========================
> Prof. Victor Lazzarini
> Dean of Arts, Celtic Studies, and Philosophy,
> Maynooth University,
> Maynooth, Co Kildare, Ireland
> Tel: 00 353 7086936
> Fax: 00 353 1 7086952
>
>> On 8 Mar 2017, at 22:03, Richard  wrote:
>>
>> This sounds like too simple to ask, but how do I do this?
>>
>> if I do in instr 0:
>>
>> gSfilepath    = "../samples/4notesMono.wav"  ; is this the correct way to initialize a string variable?
>>
>> and then try to print it like:
>>
>> prints "%s", gSfilepath
>>
>> I get the following error:
>>
>> error:  Unable to find opcode entry for 'prints' with matching argument types:
>> Found: (null) prints SS
>>
>> Richard
>>
>> Csound mailing list
>> Csound@listserv.heanet.ie
>> https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
>> Send bugs reports to
>>        https://github.com/csound/csound/issues
>> Discussions of bugs and features can be posted here
>
> Csound mailing list
> Csound@listserv.heanet.ie
> https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
> Send bugs reports to
>          https://github.com/csound/csound/issues
> Discussions of bugs and features can be posted here

Csound mailing list
Csound@listserv.heanet.ie
https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
Send bugs reports to
        https://github.com/csound/csound/issues
Discussions of bugs and features can be posted here

Date2017-03-08 22:56
FromVictor Lazzarini
SubjectRe: how to initialize and print a string variable in Csound
Works here:

 gSfilepath  init "" 

instr 1
gSfilepath = "hello/hi/how/are/you"
prints gSfilepath 
printf_i "\n%s\n", 1, gSfilepath 
endin

…

new alloc for instr 1:
hello/hi/how/are/you
hello/hi/how/are/you

========================
Prof. Victor Lazzarini
Dean of Arts, Celtic Studies, and Philosophy,
Maynooth University,
Maynooth, Co Kildare, Ireland
Tel: 00 353 7086936
Fax: 00 353 1 7086952 

> On 8 Mar 2017, at 22:44, Richard  wrote:
> 
> hmm, I still have a problem. gSfilepath is a global variable, as the name implies, so I initialize it in instr 0 as
> 
> gSfilepath init ""
> 
> Then later in some instrument, I assign the real string:
> 
> gSfilepath = "xxxxx"
> 
> but then the prints after that prints nothing...
> 
> The printf_i also complains:
> 
> printf_i “filepath: %s”, 1, gSfilepath
> 
> gives:
> 
> Error: character ?(e2)
> 
> error: syntax error, unexpected ERROR_TOKEN, expecting NEWLINE or ','  (token "?") from file reversalCab2.csd (1)
> line 158:
> >>> printf_i ? <<<
> Parsing failed due to invalid input!
> 
> 
> On 08/03/17 23:08, Victor Lazzarini wrote:
>> prints gSfilepath
>> 
>> or
>> 
>> printf_i “%s”, 1, gSfilepath
>> 
>> 
>> ========================
>> Prof. Victor Lazzarini
>> Dean of Arts, Celtic Studies, and Philosophy,
>> Maynooth University,
>> Maynooth, Co Kildare, Ireland
>> Tel: 00 353 7086936
>> Fax: 00 353 1 7086952
>> 
>>> On 8 Mar 2017, at 22:03, Richard  wrote:
>>> 
>>> This sounds like too simple to ask, but how do I do this?
>>> 
>>> if I do in instr 0:
>>> 
>>> gSfilepath    = "../samples/4notesMono.wav"  ; is this the correct way to initialize a string variable?
>>> 
>>> and then try to print it like:
>>> 
>>> prints "%s", gSfilepath
>>> 
>>> I get the following error:
>>> 
>>> error:  Unable to find opcode entry for 'prints' with matching argument types:
>>> Found: (null) prints SS
>>> 
>>> Richard
>>> 
>>> Csound mailing list
>>> Csound@listserv.heanet.ie
>>> https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
>>> Send bugs reports to
>>>       https://github.com/csound/csound/issues
>>> Discussions of bugs and features can be posted here
>> 
>> Csound mailing list
>> Csound@listserv.heanet.ie
>> https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
>> Send bugs reports to
>>         https://github.com/csound/csound/issues
>> Discussions of bugs and features can be posted here
> 
> Csound mailing list
> Csound@listserv.heanet.ie
> https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
> Send bugs reports to
>       https://github.com/csound/csound/issues
> Discussions of bugs and features can be posted here


Csound mailing list
Csound@listserv.heanet.ie
https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
Send bugs reports to
        https://github.com/csound/csound/issues
Discussions of bugs and features can be posted here