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!

Recommended Answers

All 4 Replies

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
}
if ( x > 0 && x <= 380 ) {
}

like this?

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

Thanks.

I think your mind was still focused on that Halloween candy. :)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.