IfElse

Description:              Executes one of its two parameters based upon a condition parameter.

Returns:                    Nothing

Usage:                       Script

Format:                      IfElse(Condition, TrueCase, FalseCase)

Parameters:             Condition     { Boolean }  { required }  { no default }

                                                An expression that returns true or false. If true the TrueCase is executed. If false, the FalseCase is executed. If invalid, neither case is executed.

                                    TrueCase     { expression }  { required }  { no default }

                                                The expression (typically an Execute statement) which is executed when Condition is true.

                                    FalseCase     { expression }  { required }  { no default }

                                                The expression (typically an Execute statement) which is executed when the Condition is false.

Comments:               This is simply a different name for the Cond function. The return value is the result of the evaluated case. Both cases are evaluated, in which case Cond is a more apt name.

Example:

If 1 Main;

[

  IfElse(i > 0 && i <= 50, 

         Execute(y[i] = x, 

         i++), 

  { else } 

Execute(x = i,

                 doneFlag = 1) 

  ); 

]

This statement will set the element of array y equal to i and then increment i if i is between 1 and 50 inclusive; if i is not in that range, x will be set to i and doneFlag will go true. Note that IfElse and Execute may only appear in a script.

 

See Also:

?:| Cond | Execute | IfThen