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-FileELSE IF condition condition: bexp The command ELSE IF enables nested IF's to be more clearly expressed in a program. The following examples show a simple menu selection made on a single key-press. If l, s, or e is pressed then, respectively, a load, save or, input routine is called. In all other cases the message 'unknown command' is printed. The normal nested version is as follows: DO t$=CHR$(INP(2)) ' IF t$="l" PRINT "Load text" ELSE IF t$="s" PRINT "Save text" ELSE IF t$="e" PRINT "Enter text" ELSE PRINT "unknown command" ENDIF ENDIF ENDIF ' LOOP The use of ELSE IF produces a shorter listing with smaller program indents: DO t$=CHR$(INP(2)) ' IF t$="l" PRINT "Load text" ELSE IF t$="s" PRINT "Save text" ELSE IF t$="e" PRINT "Enter text" ELSE PRINT "unknown command" ENDIF ' LOOP The program works in the following way: If the condition after IF is fulfilled (t$="l"), then the instructions between IF and the next ELSE IF are processed - PRINT "Load text" - and then the program jumps to the command ENDIF. If the condition for the first IF is not true then the other IF's are encountered. In the second case, if the condition after the ELSE IF command is met, then all instructions up to the next ELSE, ELSE IF or ENDIF (if no ELSE exists) are processed and the program jumps to the instruction after ENDIF. If neither the condition after the IF or the condition after ELSE IF is true, then the commands between ELSE and ENDIF are implemented (if an ELSE exists). Memo: This fails compiled: IF blah... ELSE IF FALSE !the entire ELSE IF-ENDIF structure ends up missing! ELSE IF 0 !same issue! ENDIF Seems ok in the interpreter.