We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
Page Index Toggle Pages: 1
when (Read 812 times)
when
Nov 5th, 2007, 6:26pm
 
I would like to introduce a new "if" like object. you can call it when. lets say i have a sketch using a live input. i want a shape to be permanently replaced when the input variable reaches 50. if you use the "if" it will only change while the input is over 50 but i want the shape to stay changed when the variable decreases and goes under 50.

instead of having some stupid variable increment every time it is over 50 and then have the shape change if the variable = 1, one could use this function. or do you have some other way of doing that?
Re: when
Reply #1 - Nov 5th, 2007, 7:29pm
 
The only way to do what you want is to store some state I'm afraid, and it's very unlikely that any new flow-control statements will be added, since processing just maps them directly into the Java versions.

So you're just going to have to keep a boolean or something aroundto check to see if the value has ever passed 50.

e.g.
Code:
boolean over50=false

//...

if(inputValue>50)
{
over50=true;
//set to true, and if never set to false, it will stay true forever.
}

if(over50)
{
doA();
}
else
{
doB();
}
Re: when
Reply #2 - Nov 5th, 2007, 7:53pm
 
okay then.. fanks for the answer:)
Page Index Toggle Pages: 1