C Block#
The Switch C Block block is used to loop the blocks within until the condition in the open space of the block is met.
They are shaped to attach stack or other C blocks above, below, or inside them.
a VEXcode Switch Blocks Example showing a Switch C Block#
if [ ] :: custom-switch
end
Select the open space of the block indicated in the image here and begin typing.
Some possible Switch Python commands to use with the Switch C block include:
while
if
for
In order for a Switch C 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, when the Left Bumper is pressed, the robot will print “The bumper was pressed!” to the console.
a VEXcode Switch Blocks Example with text inside of the switch c block and a print block saying bumper was pressed#
when started :: hat events
if [if left_bumper.pressed():] :: custom-switch
print [ Bumper was pressed! ] ▶
end