C Expandable#

The Switch C Expandable block is used to loop the blocks within a specific branch when the condition in the open space of the block is met. Additional branches can be added by expanding the block.

They are shaped to attach stack and other C blocks above, below, or inside them.

C Expandable block diagram illustrating looping branches for Switch Python commands with expand and remove icons.

Select the open space of the block indicated in the image here and begin typing.

C Expandable block interface showing options to add or remove branches and enter Switch Python commands.

To expand the block to include additional branches, select the + icon.

Icon for expanding the C Expandable block in programming, indicating the addition of branches in a loop structure.

To remove a branch from the block, select the - icon. This will remove the lowest branch.

Minus icon for removing a branch from the C Expandable block in programming interface.

Some possible Switch Python commands to use with the Switch C Expandable block include:

  • while

  • if

  • for

In order for a Switch C Expandable block to function as intended, the Switch Python commands must be entered with the correct spelling, punctuation, and indentation. Refer to the Help of each block to see the matching Switch Python command.

In this example, the code will continuously check if the Left Bumper Sensor is pressed. If the Left Bumper Sensor is not pressed, the robot will drive forward, otherwise, it will stop.

Illustration of a C Expandable block with options to add or remove branches for conditional looping in programming.