Little problem with "If --- EndIf"

Monkey Forums/Monkey Programming/Little problem with "If --- EndIf"

mteo77(Posted 2013) [#1]
Hello all.

I was wondering if it was possible to have in the If statement more than one comparison.
Example:

If x <> "up" And "down" And "left" And "right"
gotosleep()
EndIf

Basically what i want to do is to execute the gotosleep() function if x is not "up" ,"down" ,"left" ,"right" without having to do 4 different if blocks...
Hope it make sense.
Is it even possible?


Beaker(Posted 2013) [#2]
If x <> "up" And x <> "down" And x <> "left" And x <> "right"
gotosleep()
EndIf

or (probably not what you want)

If Not "up|down|left|right".Contains(x)
gotosleep()
EndIf


Midimaster(Posted 2013) [#3]
in such cases I often use...
If "up,down,left,right".Contains(x)=FALSE
    ....



mteo77(Posted 2013) [#4]
Thank you very much, the version with "contains" did the trick.
I wasn't even aware of it's existence...