GLBasic forum

Main forum => Bug Reports => Topic started by: Wild_Duck on 2008-Jan-11

Title: IF/THEN but also
Post by: Wild_Duck on 2008-Jan-11
If I have multiple statements on the same line and the first IF/THEN is not true rather than go to the next line it caries on with the rest of the line.
eg.
x=x+1;IF x>100 THEN x=0; y=y+1
This will increment y every time through the loop instead of just when x=100
Title: IF/THEN but also
Post by: AndyH on 2008-Jan-11
Might not be a bug.  I think the ; is treated like a new line rather than the old BASIC : character, so that what you've really got is more like:

x=x+1
IF x>100 THEN x=0
y=y+1

That makes more readable sense.  I guess you must use IF ... ENDIF and that is more readable anyway.
Title: IF/THEN but also
Post by: bigsofty on 2008-Jan-11
Using an IF without ENDIF will only take the 1st command after the THEN statement, then carry on to the next line or the next ';' character.

The above execution is correct and its what I would expect to happen.
Title: IF/THEN but also
Post by: Kitty Hello on 2008-Jan-11
No, you want this:
IF x>100
   x=0
   INC y,1
ENDIF