Statements

The if statement allows the conditional evaluation of one or more expressions, which, if it evaluates to true, will process the block of code within it.

An if statement, at a minimum, must contain three elements:

  • an opening if statement
  • a then statement preceding the expression for evaluation
  • a closing endif statement.

Expressions within an if statement can include the following types:

Example 1

In the following example, the @group variable will only be set if the value of @age is greater than or equal to 18:


Not a subscriber? Subscribe now.

Example 2

In the following example, if the value of @age is greater than or equal to 18, then the @group variable will only be set to adult, otherwise it will be set to child.


Not a subscriber? Subscribe now.

Example 3


Not a subscriber? Subscribe now.