Here's a copy/paste from my sketch:
if
(((men == 7) && (p > 1) && (p < 8)) ||
((men == 8) && (p > 1) && (p < 4)) ||
((men == 9) && (p > 1) && (p < 4)) ||
((men == 10) && (p == 2)) ||
((men == 11) && (((p > 1) && (p < 5)) || (p == 7))))
{
// stuff to do if "p" was found
}
[EDIT NOTE]
OK, post #3 below suggested I add "inline documentation to the above to explain what it is doing, so here it is:
if
// If menu 7 is open, are we hovering over item 2, 3, 4, 5, 6 or 7?
(((men == 7) && (p > 1) && (p < 8)) ||
// If menu 8 is open, are we hovering over item 2 or 3?
((men == 8) && (p > 1) && (p < 4)) ||
// If menu 9 is open, are we hovering over item 2 or 3?
((men == 9) && (p > 1) && (p < 4)) ||
// If menu 10 is open, are we hovering over item 2?
((men == 10) && (p == 2)) ||
// If menu 11 is open, are we hovering over item 2, 3, 4, or 7?
((men == 11) && (((p > 1) && (p < 5)) || (p == 7))))
{
// stuff to do if "p" was found
}
[END EDIT]
The above is both hard to look at, and time-consuming to place all the () brackets correctly.
Is there an easy way to accomplish the same thing?, something like:
void hasNumber(byte n)
{
if (n in [1,7,14,23,32,64,100])
return true;
else
return false;
}
"in [...]" isn't being recognized as valid code.