4.4.6 If/ElseIf/Else
The [If] command allows you to create a condition for determination of the program block.
The [ElseIf] command allows you to create a condition for determination of the program block under the If node.
The [Else] command allows you to create a program block under the If or ElseIf node.
1. Setting
If setting:
Tap the expression in the
Ifinterface to edit the condition expression.Check expression continuously: Once checked, the condition expression will be continuously checked during execution of the
Ifprogram block, and once the expression is determined to be false, theIfprogram block will be skipped at any time.
ElseIf setting:
Tap the expression in the
ElseIfinterface to edit the condition expression.Check expression continuously: Once checked, the condition expression will be continuously checked during execution of the
ElseIfprogram block, and once the expression is determined to be false, theElseIfprogram block will be skipped at any time.
2. Application
If: If theIfcondition is true, theIfprogram block will be executed.If...Else...: If theIfcondition is true, the program inside thisIfnode will be executed; otherwise the program in theElsenode will be executed.If...ElseIf...Else...: If theIfcondition is true, the program inside thisIfnode will be executed; otherwise whether theElseIfcondition is true will be determined. If theElseIfcondition is true, the program inside theElseIfnode will be executed; otherwise the program inside theElsenode will be executed.
var_0. The program starts execution and runs to Waypoint_0. Determine whether var_0 is less than or equal to 2. If var_0 is less than or equal to 2, execute MoveJ with the comment "left". If var_0 is greater than 2, determine whether var_0 is less than or equal to 5. If var_0 is greater than 2 and less than or equal to 5, execute MoveJ with the comment "right". If var_0 is greater than 5, execute MoveJ with the comment "Up".