[Csnd] if ( p4 < 12 ) then go nuts
Date | 2005-09-25 21:13 |
From | digger vermont |
Subject | [Csnd] if ( p4 < 12 ) then go nuts |
Attachments | cond-else.csd cond-elseif.csd |
Hello all, I'm getting bogged down trying to get some conditional statements to work. the statement: if ( p4 < 12 ) then print p4 else print p2 endif goes to the else statement regardless of the result of ( p4 < 12 ). Whereas using an elseif statement seems to work properly: if ( p4 < 12 ) then print p4 elseif ( p4 >= 12 ) then print p2 endif This seems to be the case for other tests I've tried ( =, >=, etc ) Is there something I'm missing? or is this a bug? I've attached two examples. I using a freshly compiled cs5 from cvs. Thanks for any help digger |
Date | 2005-09-25 22:50 |
From | "Matt J. Ingalls" |
Subject | Re: [Csnd] if ( p4 < 12 ) then go nuts |
with if statements [ both if/then and if/goto ] the rate of the variables in the conditional determines if it functions as an if-kgoto/if-then or an if-igoto/if-ithen it turns out pfields are interpreted as k-rate variables! and when you have a k-rate 'if', the if statement is essentially ignored at the irate in order to initialize anything for potential program breaks. you might try to replace the 'then's with 'ithen's or assign an ivar = p4 then do an 'if(ivar < p12) then' -m On Sun, 25 Sep 2005, digger vermont wrote: > Hello all, > I'm getting bogged down trying to get some conditional statements to > work. > > the statement: > > if ( p4 < 12 ) then > print p4 > else > print p2 > endif > Ë> goes to the else statement regardless of the result of ( p4 < 12 ). > Whereas using an elseif statement seems to work properly: > > if ( p4 < 12 ) then > print p4 > elseif ( p4 >= 12 ) then Ë> print p2 > endif > > This seems to be the case for other tests I've tried ( =, >=, etc ) Is > there something I'm missing? or is this a bug? > > I've attached two examples. > > I using a freshly compiled cs5 from cvs. > > > Thanks for any help > > digger > Ë |
Date | 2005-09-26 04:41 |
From | digger vermont |
Subject | Re: [Csnd] if ( p4 < 12 ) then go nuts |
On Sun, 2005-09-25 at 14:50 -0700, Matt J. Ingalls wrote: > > with if statements [ both if/then and if/goto ] > the rate of the variables in the conditional determines if it functions > as an if-kgoto/if-then or an if-igoto/if-ithen > > it turns out pfields are interpreted as k-rate variables! > and when you have a k-rate 'if', the if statement is essentially ignored > at the irate in order to initialize anything for potential program breaks. > > you might try to replace the 'then's with 'ithen's > or assign an ivar = p4 then do an 'if(ivar < p12) then' > Thanks for the help, Matt. I tried using ivar's and it didn't make a difference. It looks like ithen works though. I hadn't come across ithen in either the online manual or "The "Csound Book" Once again the mailing list comes through. Thanks again digger > -m > > On Sun, 25 Sep 2005, digger vermont wrote: > > > Hello all, > > I'm getting bogged down trying to get some conditional statements to > > work. > > > > the statement: > > > > if ( p4 < 12 ) then > > print p4 > > else > > print p2 > > endif > > > Ë> goes to the else statement regardless of the result of ( p4 < 12 ). > > Whereas using an elseif statement seems to work properly: > > > > if ( p4 < 12 ) then > > print p4 > > elseif ( p4 >= 12 ) then > Ë> print p2 > > endif > > > > This seems to be the case for other tests I've tried ( =, >=, etc ) Is > > there something I'm missing? or is this a bug? > > > > I've attached two examples. > > > > I using a freshly compiled cs5 from cvs. > > > > > > Thanks for any help > > > > digger > > > ™ > Ë > ™ > ™ -- Send bugs reports to this list. To unsubscribe, send email to csound-unsubscribe@lists.bath.ac.uk |
Date | 2005-09-26 16:39 |
From | Anthony Kozar |
Subject | Re: [Csnd] if ( p4 < 12 ) then go nuts |
Wouldn't this be a bug then? pfields are treated as i-rate variables everywhere else in the code. Anthony Kozar anthonykozar AT sbcglobal DOT net http://akozar.spymac.net/ Matt J. Ingalls wrote on 9/25/05 5:50 PM: > it turns out pfields are interpreted as k-rate variables! > and when you have a k-rate 'if', the if statement is essentially ignored > at the irate in order to initialize anything for potential program breaks. -- Send bugs reports to this list. To unsubscribe, send email to csound-unsubscribe@lists.bath.ac.uk |
Date | 2005-09-27 05:33 |
From | Michael Rempel |
Subject | Re: [Csnd] if ( p4 < 12 ) then go nuts |
the Then part of the if code has been buggy in past. Then has a state dependancy on the previous section of code. I think it should be explicitly rate linked. For this reason I always use goto / igoto code, even though it is less structured, it is guaranteed. For beginners, there are two basic patterns I use. Here I am using irate stuff, but this is applicable for any rate. It is best to make the rate explicit since the various rates can get confusing if you dont say what you mean at least in comments. EITHER |