Case

Verb: case

Evaluates one or more conditions and executes a command block.

Syntax

case [--name(String)] [--executeonce(Boolean)] [--priority(Numeric)] --switches(CaseSwitches) --minimum(Numeric) --maximum(Numeric) --quantity(Numeric) (Rule)=output

Inputs

Script Designer Required AcceptedTypes Description
--name Name Optional Text Name of the rule in the context of a rule set.
--executeonce Execute Once Optional Boolean Executes the rule only once.
--priority Priority Optional Number Rule execution priority in a rule set context.
--switches Options Required CaseSwitches Condition evaluation options:
  • Any: Either condition must be true for the block to be executed;
  • All: All conditions must be true for the block to be executed;
  • None: None of the conditions can be true for the block to be executed;
  • Mutually Exclusive: Of all the conditions, only one may be true for the block to be executed;
  • N: User defines how many conditions must be true for the block to be executed;
  • At Least: The user defines the minimum amount of conditions that must be true for the execution of the block;
  • Between: The user defines the minimum and maximum amount of conditions that must be true for the execution of the block.
  • --minimum Minimum Only whenOptions is AtLeast, Between Number The minimum number of conditions that must be met for command block execution.
    --maximum Maximum Only whenOptions is Between Number The maximum number of conditions that must be met for command block execution.
    --quantity Quantity Only whenOptions is N Number A specific number of conditions that must be met for the execution of the command block.

    Outputs

    Script Designer AcceptedTypes Description
    output Rule Rule Returns a rule with the parameters of the defined condition.

    Example

    Example 1: A "Number" variable is defined with the value 3. Then, three conditions are established, with only the first being true. As the parameter Options is set to "Any", if any of the three conditions are true, the command block is executed.

    defVar --name leftOperand --type Numeric --value 3
    case --switches "Any"
    	when --left "${leftOperand}" --operator "Equal_To" --right 3
    	when --left "${leftOperand}" --operator "Less_Than" --right 3
    	when --left "${leftOperand}" --operator "Greater_Than" --right 3
    then
    	logMessage --message "One of the conditions is true" --type "Info"
    endCase
    logMessage --message "End Case" --type "Info"
    // Result: One of the conditions is true.
    // End Case
    

    Example 2: A "Text" variable is defined with the value "The American flag is red, white and blue". Then, three conditions are established, with only the first two conditions being true. However, the parameter Options is set to "All", so the command block is not executed, since all conditions must be true in this case.

    defVar --name leftOperand --type String --value "The American flag is red, white and blue"
    case --switches "CaseSwitchesAll"
    	when --left "${leftOperand}" --operator "Contains" --right red
    	when --left "${leftOperand}" --operator "Contains" --right white
    	when --left "${leftOperand}" --operator "Contains" --right purple
    then
    	logMessage --message "All conditions are true." --type "Info"
    endCase
    logMessage --message "End Case" --type "Info"
    // Result: End Case
    

    Remarks

    A When command is required for each condition evaluated with Case.

    See Also

  • End Case
  • Otherwise
  • Then
  • When