Home > Language Reference > Program Flow Functions > If

If

The If...Then...Else...EndIf satement conditionally executes a group of statements, depending on the value of an expression. 

Usage

Used to make decisions during the execution of the script depending on the result of a condition (true or false). If the result is True, WinTask executes the block of steps following the If line until an EndIf is encountered, otherwise the block is skipped (if an Else line is encountered, the Else block is executed).

Syntax

If <boolean_expression> Then
      <statements>
    [Else
      <statements>]
    EndIf


Parameters

<boolean_expression>, boolean. The result of the expression must be True or False.
If the expression evaluates to TRUE, the <statements> after the THEN are executed; if the expression evaluates to FALSE, the <statements> after the ELSE are executed. The ELSE statement is optional.

See also

Logical Operators

Examples

a=0 
If a=1 Then
      beep(100)
    Else
      beep(200)
 EndIf

b=3
If b=3 Then
      beep(100)
EndIf