While
Verb: while
Repeats a command block while a condition is true.
Syntax
while --left(Variant) --operator(ConditionalOperators) --right(Variant) [--negate(Boolean)]
Inputs
Script | Designer | Required | AcceptedTypes | Description |
---|---|---|---|---|
--left | Left operand | Required | Any | Value used to evaluate the condition. |
--operator | Operator | Required | ConditionalOperators | Rule used to evaluate the condition. Options:
|
--right | Right operand | Only whenOperator is Equal_To, Greater_Than, Greater_Than_Equal_To, Less_Than, Less_Than_Equal_To, Contains, Ends_With, Begins_With, Matches | Any | Value used to evaluate the condition, along with Left operand and Operator.
|
--negate | Negate | Optional | Boolean | Negates the rule defined in Operator. |
Example
Example 1: The While command repeats a command block, incrementing a variable's value by 1 while this value is less than 5.
defVar --name verifyValue --type Numeric
while --left "${verifyValue}" --operator "Less_Than" --right 5
incrementVar --number ${verifyValue}
logMessage --message "${verifyValue}" --type "Info"
endWhile
// Result of operation:
// 1
// 2
// 3
// 4
// 5
Example 2: In this other situation, when using the Negate parameter, the instruction block is repeated, decreasing the verified value by 1, while this value is not less than 5.
// The value to be verified is equal to 8.
defVar --name verifiedValue --type Numeric --value 8
while --left "${verifiedValue}" --operator "Less_Than" --right 5 --negate
logMessage --message "${verifiedValue}" --type "Info"
decrementVar --number ${verifiedValue}
endWhile
// Result of the operation:
// 8
// 7
// 6
// 5
Remarks
When using the While command, the use of the End While command is mandatory to end the command block.