ELSE

ELSE

EXECUTES THE NEXT STATEMENT OR THE NEXT BLOCK OF STATEMENTS IF THE CONDITION IS FALSE

  • Type: Command
  • Parameter: 0
  • Group: Structures

ACTION

The statements after the ELSE are executed if the evaluation of the logical condition after IF gives a false result.

The "condition" is a single logical expression (built with comparators >, <, >=, <>, =, ...) or a complex expression combined with logical operators AND, OR, NOT and parenthesis. Only the result (True or False) is used to execute or not the following statements.

IF Condition

Statement(s)

ELSE

Statement(s)

END_IF

If the condition is true, the statement or the block of statements between IF and ELSE is executed. Otherwise, the statement or the block of statements between ELSE and END_IF is executed.

SYNTAX: IF C

  • SYNTAX 1 :
  • IF C THEN command(s)
  • C: logical expression.
  • SYNTAX 2 :
  • IF Condition
  • Statement(s)
  • ELSE
  • Statement(s)
  • END_IF
  • C: logical expression.

USE

  • IF is used to make a choice : execute a statement or a block of statements depending on a logical condition.

ERROR

  • If C is not a correct logical expression.

EXAMPLE

dim a,b

a=1:b=2

if b>a

print "b is greater than a"

else

print "b is less than or equal to a"

end_if

SEE ALSO

THEN

END_IF

WHILE

END_WHILE

REPEAT

UNTIL

AND

OR

NOT