Run Subroutine If

Verb: gosubIf

Available from: <Standard>

Performs a subroutine if a defined condition is met.

Syntax

gosubIf --label(String) [--assignments(String)] --left(Variant) --operator(ConditionalOperators) --right(Variant) [--negate(Boolean)]

Inputs

Script Designer Required AcceptedTypes Description
--label Name Required Text Name of the subroutine to be executed.
The name of a subroutine created in Start Subroutine must be entered.
--assignments Assignments Optional Text Assignments to parameters within the subroutine and their values in the current execution context.
--left Left Operand Required Any Value used to evaluate the condition.
If the defined variable is of type "Number", the initial position of its value is 0.
--operator Operator Required ConditionalOperators Rule used to assess 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 next to Left Operand and Operator.
    The value must be of the same type as Left Operand.
    --negate Negate Optional Boolean When enabled, negates the rule defined in Operator.

    Example

    Example 1: Command configured to execute a subroutine if the numeric variable created is equal to 7.

    defVar --name leftOperand --type Numeric --value 7
    gosubIf --label subRoutine --left "${leftOperand}" --operator "Equal_To" --right 7
    logMessage --message "End of execution." --type "Info"
    beginSub --name subRoutine
    	logMessage --message "The condition is true. Subroutine executed." --type "Info"
    endSub
    

    Example 2: Similar to the previous one, however, with the Negate parameter enabled.

    defVar --name leftOperator --type Numeric --value 7
    gosubIf --label subRoutine --left "${leftOperator}" --operator "Equal_To" --right 7 --negate
    logMessage --message " End of execution. " --type "Info"
    beginSub --name subRoutine
    	logMessage --message "The condition is true. Subroutine executed." --type "Info"
    endSub
    

    See Also

  • Assert Condition
  • Assign Value to a Variable If
  • Else If
  • End Do-While
  • Go to If
  • Run Subroutine