Conditional
You can control the flow of execution of tests using conditional constructs. A conditional construct begins with an If_Then action and ends with an End_If action. You can optionally include an Else action.
Conditional constructs can be nested.
These are the actions associated with the Conditional step type.
Description
(Optional) If the logical expression evaluates to False, the system executes the steps between the Else step and the End_If step.
Description
The close statement of the If_Then construct.
Description
The first step in a conditional construct. The system evaluates the logical expression in the Recognition field of the If_Then step. If the expression evaluates to True, the system executes the steps between the If_Then step and the End_If step or the Else step, if it exists. If the expression evaluates to False, the system jumps to the Else step, if it exists, or to the End_If step if there is no Else step, and continues execution.
If_Then supports these logical operators:
<>, >=, <=, >, <, =
You can use the AND and OR logical operators to specify multiple conditions.
Example
This example shows the use of multiple conditions and nested conditionals:
Type |
Action |
Recognition |
Parameters |
Value |
---|---|---|---|---|
Variable |
Set_Value |
&Integer |
|
3 |
Conditional |
If_Then |
&Integer>=1 AND &Integer<=10 OR &Integer=0 |
|
|
Log |
Message |
Determine if integer is odd or even |
|
|
Log |
Message |
Enter first nested conditional |
|
|
Conditional |
If_Then |
&Integer=0 |
|
|
Log |
Message |
Do not divide by 0 |
|
|
Conditional |
Else |
|
|
|
Variable |
Set_Value |
&Half=Divide(&Integer|2|dec=1) |
|
|
Log |
Message |
Enter second nested conditional |
|
|
Variable |
Set_Value |
&Odd=Substr(&Half|3) |
|
|
Conditional |
If_Then |
&Odd=5 |
|
|
Log |
Message |
The number is odd |
|
|
Conditional |
Else |
|
|
|
Log |
Message |
The number is even |
|
|
Conditional |
End_If |
|
|
|