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.
IndexProgramming Questions & HelpSyntax Questions › How to compare in an "If" statement
Page Index Toggle Pages: 1
How to compare in an "If" statement? (Read 563 times)
How to compare in an "If" statement?
Nov 6th, 2009, 5:56pm
 
I'd like to know how I can code the following situation.

I have a values that are dynamically loaded into a "float(Kp)" parameter.
These values can range from 0.00 to 9.00,  always in this format.

I'm trying to figure out how I can have code an 'If' statement that will check to see if Kp is greater than zero and less than 1.4......

Is it possible to code this into a 'If' statement?  If not,  is there another branching function that will allow me to perform checks like that?

thank you...

Jim
Re: How to compare in an "If" statement?
Reply #1 - Nov 6th, 2009, 7:17pm
 
yes, its easily done. you can use && (and) || (or) to check for more then just one expression to be true or false

http://processing.org/reference/logicalAND.html

so in your case it would look like this

if(Kp>0 && Kp<1.4) do XXX
Re: How to compare in an "If" statement?
Reply #2 - Nov 6th, 2009, 7:39pm
 
Cedric,

Perfect !!  I must be getting tired,  as I looked through the reference over and over again and missed that one!

Thanks again...

Jim
Page Index Toggle Pages: 1