The IF  statement

The IF statement

This statement is used to run an action or another one according to the result of an expression. If the expression is checked, a process is run ; if the expression is not checked, another process can be started.

The IF statement can be used as follows:

IF <Expression to check> THEN

  Process to run if the expression is checked

ELSE

  Process to run otherwise

END

 

WLanguage code example: The following code selects a number at random and displays a message according to the value.

Tot is currency

// Selects a number at random between 100 and 4000

Tot = Random(100, 4000)

IF Tot>2000 THEN

 Info("The amount is greater than 2000")

ELSE

 Info("The amount is less than or equal to 2000")

END

 

In this case, the expression to check corresponds to "Tot>2000".

Remark: Several code lines can be run during the process corresponding to a condition. In this case, the following syntax must be used:

 

IF <Expression to check> THEN

  Code line 1

  Code line N

ELSE

  Code line 1

  Code line N

END