short form

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

short form

Menno Knevel
i wondered if and how i could rewrite

if ibasehz == -1 then
    ibasehz =   261.625565
else
    ibasehz =   100
endif

to

ibasehz =   (ibasehz = -1 ? ibasehz = 261.625565: ibasehz =   100)

but i keep getting errors.
Can this be done in short form?
Reply | Threaded
Open this post in threaded view
|

Re: [Csnd] short form

Justin Smith
I don't think assignment returns anything useful, but the ternary operator does

ibasehz = (ibasehz == -1) ? 261.625565 : 100

the ternary expression will return 261.625565 or 100, and that will replace the value of ibasehz

On Sun, Mar 19, 2017 at 6:04 AM Menno Knevel <[hidden email]> wrote:
i wondered if and how i could rewrite

if ibasehz == -1 then
    ibasehz =   261.625565
else
    ibasehz =   100
endif

to

ibasehz =   (ibasehz = -1 ? ibasehz = 261.625565: ibasehz =   100)

but i keep getting errors.
Can this be done in short form?



--
View this message in context: http://csound.1045644.n5.nabble.com/short-form-tp5755153.html
Sent from the Csound - General mailing list archive at Nabble.com.

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
|

Re: [Csnd] short form

Menno Knevel
Thanks Justin, this works nicely
and gives me something to study.

much appreciated!