XenoGuard Documentation

If

Actions » Programming » Flow Control » If 

The action If executes one or more actions depending on the result of a conditional expression. If the condition is met, i.e. the expression result is True, the Then branch is traversed and the actions contained therein are executed. In the other case, the Else branch is processed. The Then and Else branches may be empty.

 

[-] Hide
  1. Open the Programming node in the Workspace Explorer.
  2. In the Flow Control node, select the If action.

Parameters:

The action has the following input parameters:


name Description
Left Expression The initial action, parameter, or value to be compared.

Allowed Context Scopes
[Fixed, Local, Global]
Allowed Context Types [Variable, Parameter, Result, Enum]
Operator
The operation to be used when comparing the expressions.

Allowed Context Scopes
[Fixed]
Right Expression
Another action, parameter, or value to be compared.

Allowed Context Scopes [Fixed, Local, Global]
Allowed Context Types [Variable, Parameter, Result, Enum]
[-] Hide

Here are the operators that can be used to compare the expressions:

  • State - can either be "Passed" or "Failed"
  • Contains  
  • Contains Not  
  • Contains RegEx  
  • Contains Not RegEx  
  • ==
  • !=
  • == RegEx
  • != RegEx
  • >
  • >=
  • <
  • <=
  • Item Count >
  • Item Count >=
  • Item Count <
  • Item Count <=

Branches:

The action has two branches:

name
description
Then
Contains action(s) when the condition is met.
Else
Contains action(s) when the condition is not met.

Results:

The action returns not result.

Information

The actions to be executed are placed in the "Then" branch when the specified condition is met, otherwise actions should be placed in the "Else" branch. The Else branch may or may not contain an action when it is executed.

The If action can be nested within either the "Then" branch or "Else" branch.

Example 1 (Display the comparison result in a message box):

This example compares the value of two local variables, numValue 1 and numValue 2. Both use the data type Number. The result of the comparison of the two variables is then output via Message Box.


Example 2 (Check if the parameter value is taxable):

In this example, the content of the local parameter Income is checked, which has a floating point data type. The action in the Then branch is executed if the income is greater than or equal to the specified amount and is then output via Message Box. Otherwise, the action in the Else branch is executed and then output via Write Text.

Example 3 (Run a nested If statement for a variable):

The following example uses two nested If statements to compare the value of the variable Access Key. The first If uses a regular expression "[0-9]+" to check that the value of the variable contains only the numbers 0 through 9. The second If ensures that the length of the key contains six digits. If both conditions are true, a  Message Box appears indicating that the key is valid.

See other flow control actions:

For Loop
For Each
While
Break
Label
GoTo
Parallel
On Error Continue
On Error GoTo
Abort
Abort on Error