02-23-2011, 04:29 PM
Have you had enough of me yet? :-D
I'm having a weird issue with ELSE, but I'm not sure if I'm doing something wrong or not. Take a look at this test program:
I would expect the output from this to be like this:
But it's actually like this:
Condition "3" is running correctly, but the final ELSE block is also being processed so you get two lines output if num is 3. Have I messed up the syntax there? The behaviour is certainly different to how it used to be, as an old program that used to be okay is now failing.
I've tried this in 2100 and also 1866 and it does the same in both, so it must've been a while since I compiled it! :-)
I'm having a weird issue with ELSE, but I'm not sure if I'm doing something wrong or not. Take a look at this test program:
Code:
dim num as ubyte
cls
num = 1
test()
num = 2
test()
num = 3
test()
num = 4
test ()
sub test
IF num = 1 THEN
PRINT "1"
ELSEIF num = 2 THEN
PRINT "2"
ELSEIF num = 3 THEN
PRINT "3"
ELSE
PRINT "X"
END IF
PRINT "---"
end sub
I would expect the output from this to be like this:
Code:
1
---
2
---
3
---
X
---
But it's actually like this:
Code:
1
---
2
---
3
X
---
X
---
Condition "3" is running correctly, but the final ELSE block is also being processed so you get two lines output if num is 3. Have I messed up the syntax there? The behaviour is certainly different to how it used to be, as an old program that used to be okay is now failing.
I've tried this in 2100 and also 1866 and it does the same in both, so it must've been a while since I compiled it! :-)