1
1
Fork 0
mirror of https://github.com/QB64-Phoenix-Edition/QB64pe.git synced 2024-07-01 13:50:36 +00:00
QB64-PE/internal/help/ELSE_1111.txt
Roland Heyder aeb9c0668b Updates help files for use with new Wiki parser (2nd try)
Note: Many files were removed (not yet existing/empty pages). The parser will try to download them on demand and will auto-generate text for missing pages (eg. most _gl pages).
2022-05-21 00:18:31 +02:00

66 lines
1.4 KiB
Plaintext

{{QBDLDATE:05-20-2022}}
{{QBDLTIME:23:12:57}}
[[ELSE]] is used in [[IF...THEN]] or [[SELECT CASE]] statements to offer an alternative to other conditional statements.
{{PageSyntax}}
''Single-line syntax:''
: [[IF]] {{Parameter|condition}} [[THEN]] ''{code}'' [[ELSE]] ''{alternative-code}''
''Block syntax:''
: [[IF]] {{Parameter|condition}} [[THEN]]
:: ''{code}''
:: ⋮
: [[ELSEIF]] {{Parameter|condition2}} [[THEN]]
:: ''{code}''
:: ⋮
: [[ELSE]]
:: ''{alternative-code}''
:: ⋮
: [[END IF]]
{{PageDescription}}
* ELSE is used in a IF block statement to cover any remaining conditions not covered in the main block by IF or [[ELSEIF]].
* [[CASE ELSE]] covers any remaining conditions not covered by the other CASE statements.
* ELSE can also be used as a false comparison to a true IF statement when a condition will only be true or false.
* Other [[IF...THEN]] statements can be inside of an ELSE statement.
{{PageExamples}}
''Example 1:'' One line IF statement
{{CodeStart}}
IF x = 100 THEN PRINT "100" ELSE PRINT "Not 100"
{{CodeEnd}}
''Example 2:'' Multiple line IF statement block
{{CodeStart}}
IF x = 100 THEN ' code executed MUST be on next statement line!
PRINT "100"
ELSE PRINT "Not 100"
END IF
{{CodeEnd}}
''Example 3:'' To alternate between any two values (as long as the value after ELSE is the same as the condition)
{{CodeStart}}
IF a = 3 THEN a = 5 ELSE a = 3
{{CodeEnd}}
{{PageSeeAlso}}
* [[ELSEIF]]
* [[IF...THEN]]
{{PageNavigation}}