If
Verb: if
Executes a command block if the defined condition is met.
Syntax
if --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;
Value must be of the same type as Left operand. |
--negate | Negate | Optional | Boolean | Negates the rule defined in Operator. |
Example
Example 1: A student's average is stored in a numeric variable. If defines that if the value is greater than 7, a message appears on the screen stating that the student can participate in a draw.
defVar --name studentAverage --type Numeric --value 8
if --left "${studentAverage}" --operator "Greater_Than" --right 7
messageBox --title Grade --text "Congratulations! You can participate in the draw!" --icon "Information" --buttons "OK" --defaultbutton "FirstButton"
endIf
logMessage --message "${studentAverage}" --type "Info"
// Checks student average and reports you can participate in the draw, as the value is greater than 7.
Example 2: Similar to the previous example, now using the Negate parameter. In this case, the message about the draw does not appear.
defVar --name studentAverage --type Numeric --value 8
if --left "${studentAverage}" --operator "Greater_Than" --right 7 --negate
messageBox --title Grade --text "Congratulations! You can participate in the draw!" --icon "Information" --buttons "OK" --defaultbutton "FirstButton"
endIf
logMessage --message "${studentAverage}" --type "Info"
// Checks value of studentAverage, but does not show message since value is greater than 7.
Remarks
A condition beginning with If always ends with End If.
If the variable defined in Left operand is of the Number type, the default value is 0.