25.84. IF condition THEN

[<<<] [>>>]

Conditional execution. There are two different ways to use this command: single line IF and multi line IF.

A single line IF has the form

IF condition THEN command

There is no way to specify any ELSE part for the command in the single line version. If you need ELSE command you have use multi line IF.

The multi line IF should not contain any command directly after the keyword THEN. It should have the format:

IF condition THEN
  commands
ELSE
  commands
END IF

The ELSE part of the command is optional, thus the command can have the format

IF condition THEN
  commands
END IF

as well. To be very precise the full syntax of the multi-line IF command is:

IF condition THEN
 commands
[ ELSE IF | ELSEIF | ELSIF | ELIF 
  commands
  ... ]
[ ELSE
  commands ]
END IF | ENDIF

You can use as many ELSE IF branches as you like and at most one ELSE branch.

The keywords ELSE IF, ELSEIF and others are allowed for ease program porting from other BASIC dialect. There is no difference between the interpretation. The same is true for END IF in two words and written into a single keyword ENDIF.


[<<<] [>>>]