11-12-2018, 02:29 PM
oblo Wrote:Hi all
Instead of...
Code:IF var = 1 OR var = 2 OR var = 3 OR var = 4 THEN
... is there any way to achieve the same in a more efficient way? Something like that:
Code:IF var = (1 OR 2 OR 3 OR 4) THEN
Thanks in advance and cheers
No, unfortunately not. OR joins two boolean expressions, and if you do "1 OR 2" that evaluates to "TRUE OR TRUE" = TRUE which is not what you are looking for.
While in English that might sound sensible, no programming language allows that shortcut with booleans. Some languages allow a switch command to test for multiple IF cases, but it's not available in ZXB.
You need to test (var=1) OR (var=2) to have the right true false values either side of the OR. You might be able to have something like "IF INT ver >0 AND INT var < 5 THEN" if the numbers are in a range, though.