Topic : The GFA-Basic Compendium Author : GFA Systemtechnik GmbH Version : GFABasic.HYP v2.98 (12/31/2023) Subject : Documentation/Programming Nodes : 899 Index Size : 28056 HCP-Version : 3 Compiled on : Atari @charset : atarist @lang : @default : Document not found @help : Help @options : +g -i -s +z @width : 75 @hostname : STRNGSRV @hostname : CAB @hostname : HIGHWIRE @hostname : THING View Ref-FileIF condition [THEN] (instructions) ELSE (instructions) ENDIF condition: bexp These commands enable one to specify that a section of a program will only be executed if a logical condition is met. The following example demonstrates this: IF a=1 THEN PRINT "a is equal to 1" b=2 ENDIF In this case a=1 is the logical condition. The instructions in the lines between IF and ENDIF are processed only if this logical condition is met. If it is untrue, then the program continues with the commands after the ENDIF and the command THEN is not considered. It should be noted that it is sufficient to use the form: IF a=1 instead of IF a=1 THEN The following construction is somewhat more complex: IF a=1 PRINT "a is equal to 1" ELSE PRINT "a is not equal to 1," PRINT "it is equal to ";a ENDIF In this case shown above, the instructions between IF and ELSE are processed if the logical condition after the IF is true. The program then continues execution after the ENDIF. However, if the condition after IF is not fulfilled, then the instructions between ELSE and ENDIF become effective. Again, program execution is continued after the ENDIF. Note: Any numerical expression, which is not equal to 0, i.e. is FALSE, is considered to be true. The logical value for TRUE is -1 but any non-zero value is considered to be equivalent. Example: x=1 IF x PRINT "x is true" ENDIF INPUT y IF x=9 OR ODD(y) PRINT "y is an odd number" ELSE PRINT "y is an even number" ENDIF --> First the message 'x is true' is displayed and then a numeric input is requested. Since x cannot be 9, the text appears 'y is an odd number', if you have entered an odd number, otherwise 'y is an even' is displayed. Memo: This fails compiled: IF FALSE !the entire IF-ENDIF structure ends up missing! ENDIF IF 0 !same issue! ENDIF Seems ok in the interpreter.