Skip to content
Andrew Owen edited this page May 30, 2023 · 2 revisions

IF


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.

Parameters

  • truth_value is a numeric expression.
  • line_number_false and line_number_true are existing line numbers.
  • compound_statement_false and compound_statement_true are compound statements, consisting of at least one statement, optionally followed by further statements separated by colons (:). The compound statements may contain nested IF to THEN to ELSE statements.

Notes

  • The comma is optional and ignored.
  • ELSE clauses are optional; they are bound to the innermost free IF statement if nested. Additional ELSE clauses that have no matching IF are ignored.
  • All clauses must be on the same program line.
  • THEN and GOTO 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.

Errors

  • If truth_value has a string value: Type mismatch.
  • truth_value equals 0 and line_number_false is a non-existing line number, or truth_value is nonzero and line_number_true is a non-existing line number: Undefined line number.

Welcome to the SE BASIC wiki


  • Press RETURN to return to this menu.
  • Enter the name of a TOPIC to display it.
  • Enter EXIT to return to BASIC.

Choose from the following topics:

  1. Quick start guide: QUICK
  2. User's guide: USER
  3. Configuration guide: CONFIG
  4. Language guide: LANGUAGE
  5. Language reference: BASIC
  6. Technical reference: TECH
  7. Developer's guide: DEV
  8. Acknowledgemets: CREDITS
  9. Licenses: LICENSE
Clone this wiki locally