{{htmlmetatags>metatag-robots=() metatag-title=(IF...THEN...ELSE...ELSEIF...ENDIF | ugBASIC User Manual) metatag-keywords=(ugBASIC,Commodore 64,Commodore PLUS/4,ZX Spectrum) metatag-description=(Manual page for IF...THEN...ELSE...ELSEIF...ENDIF) metatag-media-og:image=(:ugbasic:logo-ugbasic-fb.png) metatag-og:title=(IF...THEN...ELSE...ELSEIF...ENDIF | ugBASIC User Manual) metatag-og:description=(Manual page for IF...THEN...ELSE...ELSEIF...ENDIF) }} ====== ugBASIC User Manual ====== ===== IF...THEN...ELSE...ELSEIF...ENDIF ✓ ===== ===== SYNTAX ===== IF expression THEN ... ELSE ... ENDIF IF expression THEN ... ELSEIF expression2 THEN ... ... ELSE ... ENDIF ==== PURPOSE ==== Implement a conditional jump. This implementation assumes that an expression passed as a parameter is 0 (for false) and not zero (for true). In this case, if the expression is zero, it jumps directly to the statement following the corresponding ''ENDIF'' (or ''ELSE'', if present). Otherwise, the following code will be executed (up to ''ENDIF'' or ''ELSE''). ==== EXAMPLE ==== IF ( x == 42 ) THEN : x = 0 : ELSE : x = 1 : ENDIF IF ( x == 42 ) THEN : x = 0 : ELSE IF y == 0 THEN : y = 42 : ELSE : x = 1 : ENDIF IF ( x == 42 ) THEN x = 0 ELSE IF y == 0 THEN y = 42 ELSE x = 1 ENDIF See also the following example files: * ''[[https://github.com/spotlessmind1975/ugbasic/tree/main/examples/control_returning_01.bas|control_returning_01.bas]]'' * ''[[https://github.com/spotlessmind1975/ugbasic/tree/main/examples/control_returning_02.bas|control_returning_02.bas]]'' * ''[[https://github.com/spotlessmind1975/ugbasic/tree/main/examples/control_popping_91.bas|control_popping_91.bas]]'' ==== ABBREVIATION ==== If...Th...El...Eif...Ei ==== AVAILABLE ON ==== * Atari (400/800) * Atari XL/XE * Commodore 128 (MOS 8502) * Commodore 128 (Zilog Z80) * Commodore 64 * Commodore 64+REU * TRS-80 Color Computer * TRS-80 Color Computer 3 * ColecoVision * Amstrad CPC 664 * Dragon 32 * Dragon 64 * Thomson MO5 * Thomson MO5 * Olivetti Prodest PC128 * Commodore PLUS/4 * SEGA SC-3000 * SEGA SG-1000 * VG-5000 * Commodore VIC-20 * ZX Spectrum 48 ==== ANY PROBLEM? ==== If you have encountered a problem using this command, if you think there is a bug or the explanation is unclear, please [[https://github.com/spotlessmind1975/ugbasic/issues/new?title=ISSUE ON IF...THEN...ELSE...ELSEIF...ENDIF|open an issue]] for this keyword on GitHub. Thank you!===== POWERED BY ===== [[:ugbasic:user:index|{{ :ugbasic:user:logo-ugbasic.png?nolink&600 |}}]]