1
1
Fork 0
mirror of https://github.com/QB64-Phoenix-Edition/QB64pe.git synced 2024-07-04 06:00:23 +00:00
QB64-PE/internal/help/ELSEIF_111111.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

59 lines
1.4 KiB
Plaintext

{{QBDLDATE:05-20-2022}}
{{QBDLTIME:23:12:59}}
[[ELSEIF]] is used in an [[IF...THEN]] block statement to offer an alternative condition.
{{PageSyntax}}
: [[IF]] {{Parameter|condition}} [[THEN]]
:: ''{code}''
:: ⋮
: [[ELSEIF]] {{Parameter|condition2}} [[THEN]]
:: ''{code}''
:: ⋮
: [[ELSE]]
:: ''{alternative-code}''
:: ⋮
: [[END IF]]
{{PageDescription}}
* ELSEIF statements require a '''separate''' code block line with [[THEN]] for each alternative condition.
* There can be more than one [[ELSE]] IF statement in a single-line IF statement.
* If there is only one possible alternative condition (such as 0 or [[NOT]] 0), use [[ELSE]] instead.
* If the comparisons are based on multiple conditions being true, it may require many ELSEIF comparisons. ELSE could help cover some of those conditions.
* You can use [[SELECT CASE]] when IF blocks have a long list of alterative ELSEIF conditions.
{{Template:RelationalTable}}
{{PageExamples}}
''Example 1:'' IF statement using ELSE IF in one statement line.
{{CodeStart}}
IF x = 100 THEN COLOR 10: PRINT x ELSE IF x > 100 THEN COLOR 12: PRINT x ELSE PRINT "< 100"
{{CodeEnd}}
''Example 2:'' IF statement block
{{CodeStart}}
IF x = 100 THEN ' must place ANY code on next line!
COLOR 10: PRINT x
ELSEIF x > 100 THEN COLOR 12: PRINT x
ELSE : PRINT "< 100"
END IF
{{CodeEnd}}
{{PageSeeAlso}}
*[[ELSE]], [[END IF]]
*[[IF...THEN]]
{{PageNavigation}}