IF - source-solutions/HELP GitHub Wiki
IF truth_value {THEN|GOTO} [compound_statement_true|line_number_true [anything]][ELSE [compound_statement_false|line_number_false [anything]]]
If truth_value
is non-zero, executes compound_statement_true
or jumps to
line_number_true. If it is zero, executes compound_statement_false
or jumps to
line_number_false.
-
truth_value
is a numeric expression. -
line_number_false
andline_number_true
are existing line numbers. -
compound_statement_false
andcompound_statement_true
are compound statements, consisting of at least one statement, optionally followed by further statements separated by colons (:
). The compound statements may contain nestedIF
toTHEN
toELSE
statements.
- The comma is optional and ignored.
-
ELSE
clauses are optional; they are bound to the innermost freeIF
statement if nested. AdditionalELSE
clauses that have no matchingIF
are ignored. - All clauses must be on the same program line.
-
THEN
andGOTO
are interchangeable; which one is chosen is independent of whether a statement or a line number is given.GOTO PRINT 1
` is fine. - As in
GOTO
, anything after the line number is ignored.
- If
truth_value
has a string value: Type mismatch. -
truth_value
equals0
andline_number_false
is a non-existing line number, ortruth_value
is nonzero andline_number_true
is a non-existing line number: Undefined line number.