Re: if then problem
Date | 2006-05-05 11:58 |
From | Istvan Varga |
Subject | Re: if then problem |
Attachments | None |
Date | 2006-05-05 12:35 |
From | Rory Walsh |
Subject | if then problem |
Can anyone spot the problem here. The 'if then' statement for ktest and ktest2 always returns true? No doubt it's something really stupid that I just can't see? instr 2 Sname strget 1 ichnls filenchnls Sname ksearch chnget "skip" ktrig changed ksearch reset: iskip = i(ksearch); if(ktrig==0) then goto contin else reinit reset endif contin: ktest = 1; ktest2 = 2; if ktest>ktest2 then print giflen event_i "e", 0, 0, 0.1 endif if ichnls==2 then a1, a2 soundin Sname, iskip outs a1, a2 elseif ichnls==1 then a1 soundin Sname, iskip outs a1, a1 endif rireturn endin |
Date | 2006-05-05 13:25 |
From | Rory Walsh |
Subject | Re: if then problem |
Thanks Istvan, that makes perfect sense. Rory. Istvan Varga wrote: > On Friday 05 May 2006 13:35, Rory Walsh wrote: > >> Can anyone spot the problem here. The 'if then' statement for ktest and >> ktest2 always returns true? No doubt it's something really stupid that I >> just can't see? > > If you compare k-rate values, then the code for both the 'if' and 'else' > branch always gets executed at i-time, because the result of the comparison > is undefined at i-time. So, the flow of control just "falls through" any > if/then/else with a k-rate condition at init time, to avoid the possibility > of unexpected "not initialised" errors. If you want if/then/else to have > any effect at i-time, compare i-rate values instead. |