How to Use Waiting or Non-waiting Blocks to Control Program Flow
Non-waiting blocks have the stack continue even if the block’s behavior is not yet complete.
The “drive” block is a good example of a non-waiting block. In the example below, the robot doesn’t move because the “drive” block begins but then the “stop driving” block stops it before the motors can move.
Non-waiting blocks are useful when you want to perform multiple behaviors at the same time.
Waiting blocks pause the rest of the stack until that block’s behavior has been completed.
Most waiting blocks are found among the Motion and Drivetrain blocks.
If a VEX IQ Clawbot needs to retrieve a cube, you can use waiting blocks to have the robot carry out each behavior individually.
Blocks that Can Wait or Not Wait
VEXcode IQ Blocks lets users change the following waiting blocks to non-waiting blocks with one click: “spin for,” “spin to position,” “drive for,” “turn for,” and “turn to heading”.
By changing the block for opening the claw to non-waiting and changing the block for raising the arm to non-waiting, the Clawbot drives forward while the claw opens and drives in reverse while the arm raises.
This approach to retrieving a cube is better in competition settings because it saves time.