I need to have a function like this:
if (x == 1){
do some amazing things.

I need it to check to see if x == 1 through 380 or more.
But I really don't want to waste 4 hours doing this:
if (x == 1 || x == 2 || x == 3 || ... || x == 380)

I am using a mouse peripheral and I need it to check to see if the mouse x/y coords are, when clicked, in a certian place on the screen. So essentially "x == 1" is the #1 pixel on the x coords.

If someone can help me find a way to do this faster, THANKS!

8 Years
Discussion Span
Last Post by Clinton Portis

you can easily perform a test on an entire range of values:

//If 'x' is greater than or equal to 1 AND 'x' is less than or equal to 380
if(x >= 1 && x <= 380)
     //Do amazing things

Edited by Clinton Portis: n/a


Thanks so much, I probably would have found that out eventually. I don't know what was going through my mind...


This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.