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:
  • Begins with
  • Contains
  • Ends with
  • Equal to
  • Greater than
  • Greater than or equal to
  • Is empty
  • Is null
  • Is null or empty
  • Is true
  • Less than
  • Less than or equal to
  • Matches
  • --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.

    See Also

  • Assert Condition
  • Assign Value to a Variable If
  • Begin Do-While
  • Case
  • Continue
  • Else
  • Else If
  • End Case
  • End Do-While
  • End For Each
  • End If
  • End While
  • Execute Subroutines
  • For
  • For Each
  • Go to
  • Go to If
  • Insert Label
  • Interrupt Loop
  • Next
  • Otherwise
  • Return from Subroutine
  • Run Subroutine
  • Run Subroutine If
  • Then
  • When
  • While