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 › Problems with this comparison statement...
Page Index Toggle Pages: 1
Problems with this comparison statement... (Read 856 times)
Problems with this comparison statement...
Nov 10th, 2009, 6:46pm
 
Ok, I must admit I'm completely stumped on this one.  In my sketch,  I have the following variable declarations (plus many more) at the beginning of the sketch.

int AlertLevel
int AlertKpScale

then further down in the code,  I compare these two values in an 'if' statement :

if (AlertKpScale == AlertLevel);{
 alertsound.loop();
 }

Right before this comparison I perform a println statement to check both of the values. The debug window shows that the variable 'AlertKpScale' is 5,  and the variable AlertLevel is 1

I can't for the life of me figure out why this comparison is evaluating as true, and acting on the alertsound.loop() function... I only want the alertsound.loop() function to fire if the two variables are equal.

What the heck am I missing....it's got to be simple,  but I sure can't figure it out !!

Thanks for any help you can offer.....


Re: Problems with this comparison statement...
Reply #1 - Nov 10th, 2009, 9:20pm
 
remove the ;
right now it executes the empty line after your if statement when true and plays alertsound no matter because it doenst belong to it ...
if you remove the ; it should be fine.
Re: Problems with this comparison statement...
Reply #2 - Nov 11th, 2009, 1:40am
 
Wow, well spotted, Cedric!  Smiley
Re: Problems with this comparison statement...
Reply #3 - Nov 11th, 2009, 4:11am
 
Thank you Cedric.....now I feel really stupid....you have no idea how long I worked with that statement,  trying to get it to function correctly.

Re: Problems with this comparison statement...
Reply #4 - Nov 11th, 2009, 5:53am
 
hehe, dont ask me how long i spend with problems like this too... but thats the good thing about this discussion board, you can benefit from the others experience.

Re: Problems with this comparison statement...
Reply #5 - Nov 11th, 2009, 6:18am
 
Yes,  this board has been a tremendous help for me...I've learned a LOT...thanks to everyone for their patience with me...
Page Index Toggle Pages: 1