IF ... THEN ... ELSE

Syntax:

if <any relation> [and | or <any relation>] then <statements> [else <statements>]

or, since version 2.1:

if <any relation> [and | or <any relation>] then
  <statements>
[else
  <statements>]
endif

Conditional structure. Executes the statements after THEN if the expression evaluates to true, otherwise the statements after ELSE, if present. ELSE is optional.

Current limitations:

  • Only one conditional operation (AND/OR) is supported
  • THEN may not be omitted

Examples:

if x >= y/z then print "yes, expression is true"
if a = b then print "they are equal" else print "they are not equal"
if a = b or a < 2 then print "they are equal or a is less than two"

Please refer to the Operators page for the list of supported operators.

Performance tip

An ON … GOTO or ON … GOSUB construct is faster than its IF … THEN GOTO/GOSUB equivalent. Please refer to the ON construct for details.

This website uses cookies. By using the website, you agree with storing cookies on your computer. Also you acknowledge that you have read and understand our Privacy Policy. If you do not agree leave the website.More information about cookies

Discussion

Enter your comment. Wiki syntax is allowed: