[Csnd] how to initialize and print a string variable in Csound

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

[Csnd] how to initialize and print a string variable in Csound

zappfinger
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
[hidden email]
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
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: [Csnd] how to initialize and print a string variable in Csound

Victor Lazzarini
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 <[hidden email]> 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
> [hidden email]
> 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
[hidden email]
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
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: [Csnd] how to initialize and print a string variable in Csound

zappfinger
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 <[hidden email]> 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
>> [hidden email]
>> 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
> [hidden email]
> 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
[hidden email]
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
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: [Csnd] how to initialize and print a string variable in Csound

zappfinger
In reply to this post by Victor Lazzarini
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 <[hidden email]> 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
>> [hidden email]
>> 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
> [hidden email]
> 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
[hidden email]
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
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: [Csnd] how to initialize and print a string variable in Csound

Victor Lazzarini
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 <[hidden email]> 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 <[hidden email]> 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
>>> [hidden email]
>>> 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
>> [hidden email]
>> 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
> [hidden email]
> 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
[hidden email]
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
Loading...