4.4.7 Switch/Case/Default

On [Switch] page, you can create multiple switches, and control the flow of the program according to the value of the variables. You can set whether to add a Default program block to the program tree. For "Synchronize", see the description of "Synchronize" in "4.3.6 Assignment".

You can use the [Case] command to create a Case program block under Switch.

Case node can be inserted under Switch node only.

Application

  • Switch...Case...Default...: Execute different Case program blocks by determining the conditions. You can enter the selection and determination condition expression in the Switch interface, and enter the matching value in the Case interface. When the program runs the Switch node, it first calculates the value of the expression of the Switch node, which is then compared with the values of the Case under the Switch: If the same value is matched in all the conditions, the Case program block will be executed; if no matching Case value is found, the "Default" program block under that Switch will be executed.
    • A Switch can include 0 to several Case program blocks.
    • A Switch can include 0 to 1 "Default" program block, which can be added by checking the "Add Default " in the Switch.
Example: Set an initial variable var_0. Access the program and run it to Waypoint_0. Determine whether var_0 is equal to 0. If var_0 is equal to 0, run MoveJ with the comment "Right"; If var_0 is not equal to 0, determine whether var_0 is equal to 1. If var_0 is equal to 1, run MoveJ with the comment "Left". If var_0 is neither equal to 0 nor equal to 1, run MoveJ with the comment "High".

results matching ""

    No results matching ""