Csound Csound-dev Csound-tekno Search About

strtodk in conditional

Date2016-09-15 19:24
FromOeyvind Brandtsegg
Subjectstrtodk in conditional
Hi,
I wonder why this gives an error on an empty string

        if (strlenk(Spartitionlen)>0) then
        gkpartitionlen strtodk Spartitionlen
        endif

I thought that the conditional branch would not be entered until the
string had changed, but it seems it is running at init also.

Below is a full csd, it will give an error on strtodk.
If instr 2 is enabled, the error disappears, but it is kind of bulky
needing to do that.



-n -d -+rtmidi=NULL -M0 -m0d



        gkpartitionlen init 1024

        instr 1
        Spartitionlen chnget "partitionlength"
        k1 changed Spartitionlen
        if (strlenk(Spartitionlen)>0) then
        gkpartitionlen strtodk Spartitionlen
        endif
        printk2 gkpartitionlen
        endin

        instr 2
        chnset  "1234567", "partitionlength"
        endin



i1  0.1  0.1
;i2  0.0  0.1
e





Date2016-09-15 20:34
FromVictor Lazzarini
SubjectRe: strtodk in conditional
It could be that strtodk runs at i and k time. K conditionals are ignored at i time to allow for opcode initialisation.

I need to look at strtodk to have a better idea.

Victor Lazzarini
Dean of Arts, Celtic Studies, and Philosophy
Maynooth University
Ireland

> On 15 Sep 2016, at 19:24, Oeyvind Brandtsegg  wrote:
> 
> Hi,
> I wonder why this gives an error on an empty string
> 
>        if (strlenk(Spartitionlen)>0) then
>        gkpartitionlen strtodk Spartitionlen
>        endif
> 
> I thought that the conditional branch would not be entered until the
> string had changed, but it seems it is running at init also.
> 
> Below is a full csd, it will give an error on strtodk.
> If instr 2 is enabled, the error disappears, but it is kind of bulky
> needing to do that.
> 
> 
> 
> -n -d -+rtmidi=NULL -M0 -m0d
> 
> 
> 
>        gkpartitionlen init 1024
> 
>        instr 1
>        Spartitionlen chnget "partitionlength"
>        k1 changed Spartitionlen
>        if (strlenk(Spartitionlen)>0) then
>        gkpartitionlen strtodk Spartitionlen
>        endif
>        printk2 gkpartitionlen
>        endin
> 
>        instr 2
>        chnset  "1234567", "partitionlength"
>        endin
> 
> 
> 
> i1  0.1  0.1
> ;i2  0.0  0.1
> e
> 
> 
> 
> 
> 
> 
> -- 
> 
> Oeyvind Brandtsegg
> Professor of Music Technology
> NTNU
> 7491 Trondheim
> Norway
> Cell: +47 92 203 205
> 
> http://www.partikkelaudio.com/
> http://soundcloud.com/brandtsegg
> http://flyndresang.no/
> http://soundcloud.com/t-emp
> 
> 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