Using Switch Blocks to Transition from Blocks to Text-Based Coding

Switch incorporates familiar elements of block-based programming and integrates text-boxes where text commands can be typed.

Note: Switch Blocks are only compatible with Python.


Switch provides students a natural bridge from Blocks into text-based coding. As students gain familiarity with the logic and sequencing of commands, they can begin to convert a project one block at a time. 

This allows students to continue working with the logic flow of a block-based program where they can physically see things like the wrapping of a loop around other blocks while also beginning to experiment with text commands themselves. Once the blocks are converted to Switch, students can easily change parameters and begin to understand the syntax of the text command. This section will walk you through a student's use of Switch to explain how you can use these blocks in a VEXcode project.

Getting Started with Switch Blocks

To get started with coding with Switch Blocks, you must have:

  • A computer (not a mobile device).

Diagram illustrating V5 Blocks tutorials, showcasing various block types and their connections for educational purposes in robotics programming.

When a Block is converted to a Switch Block, C++ in the Code Viewer will be disabled.

Converting Blocks to Switch

Convert a Single Block to Switch

Diagram illustrating V5 blocks for robotics tutorials, showcasing various block types and their functions within the VEX programming environment.

Right-click on the Block you want to convert to a Switch Block.

Diagram illustrating V5 blocks used in tutorials, showcasing various block types and their connections for educational purposes in robotics programming.

Select Convert Block to Switch Block.

Diagram illustrating various V5 blocks used in robotics, highlighting their functions and connections in a tutorial format for enhanced understanding of programming concepts.

The Block will now be switched to a Switch Block with the same parameters.

Diagram illustrating V5 blocks used in robotics, showcasing various components and their connections in a tutorial format for educational purposes.

To turn a Switch Block back into a Block after conversion select the Undo button.

Convert Multiple Blocks to Switch

Diagram illustrating V5 blocks for robotics, showcasing various block types and their connections in a tutorial format for educational purposes.

Right-click the top of the stack you wish to convert to a Switch Block.

Diagram illustrating various V5 blocks used in robotics programming, showcasing their functions and connections in the context of Blocks Tutorials.

Select Convert Stack to Switch Block.

Diagram illustrating the various types of blocks used in V5 robotics tutorials, showcasing their functions and relationships within the V5 system.

The Block you right-clicked and all Blocks underneath it will be converted to a Switch Block.

Convert Blocks Inside a Wrapper to Switch

You can convert a Wrapper and all of its content to Switch with one click.

Diagram illustrating various V5 blocks used in robotics tutorials, showcasing their functions and connections for educational purposes.

Right-click the Wrapper you want to convert.

Diagram illustrating various V5 blocks used in programming tutorials, showcasing their connections and functionalities in a robotics context.

Select Convert Wrapper and Contents to Switch Block.

Diagram illustrating various V5 blocks used in robotics programming, showcasing their functions and connections in a tutorial format for enhanced understanding of V5 block-based coding.

All of the contents of the Wrapper will be converted to a single Switch Block.

Use a Switch Block

Add a Switch Block from the Toolbox

Click and drag a Switch Block from the Toolbox.

Type in a Switch Block

Select the Switch Block's text field, then enter your desired command.

Copy and Paste Text Inside a Switch Block

Click and drag to highlight text in the Switch Block. Right-click and select Copy. Next, click inside another Switch Block. Finally, right-click and select Paste to transfer the text.

Additional Switch Blocks

Switch blocks follow the same shape conventions as other blocks. The table here shows the comparison between the block shape, its meaning, and the Switch blocks of the same type.

Block Shape Description Block Examples Switch Examples
Hat blocks Start a stack of blocks and are shaped to attach blocks below them. Diagram illustrating V5 blocks used in robotics tutorials, showcasing various block types and their connections for programming tasks. Diagram illustrating various V5 blocks used in robotics programming, showcasing connections and functionalities for enhanced understanding in the Blocks Tutorials section.
Stack blocks Perform main commands. They are shaped to attach above or below other stack blocks. Diagram illustrating V5 blocks tutorial concepts, showcasing various block types and their connections for programming VEX robotics. Diagram illustrating V5 blocks used in robotics tutorials, showcasing various components and their connections for educational purposes.
Boolean blocks Return a condition as either true or false and fits inside any blocks with hexagonal (six-sided) inputs for other blocks. Diagram illustrating various V5 blocks used in robotics programming, showcasing their connections and functionalities, as part of the Blocks Tutorials in the V5 Category Description. Diagram illustrating various V5 Blocks used in robotics programming, showcasing block types and their connections for effective coding in the VEX V5 system.
Reporter blocks Report values in the form of numbers and fits inside any blocks with oval inputs for other blocks. Diagram illustrating VEX V5 blocks used in programming tutorials, showcasing various block types and their functions for educational purposes. V5 Blocks tutorial image showing various block types and their configurations, illustrating the features and functionalities available for users in the V5 robotics platform.
C blocks Loop the block(s) within them or check if a condition is true or false. They are shaped to attach stack blocks above, below, or inside them. Illustration of V5 blocks used in robotics programming, showcasing various block types and their connections in a tutorial format for educational purposes. Diagram illustrating various blocks used in V5 robotics, showcasing their functions and connections in a tutorial context. Diagram illustrating various V5 blocks used in robotics programming, showcasing their connections and functions in a tutorial context. Diagram illustrating various V5 blocks used in robotics programming, highlighting their functions and connections in a tutorial format for understanding the V5 system.

 

1  Weintrop, David, and Uri Wilensky. "How block-based, text-based, and hybrid block/text modalities shape novice programming practices."  International Journal of Child-Computer Interaction 17 (2018): 83-92

For more information, help, and tips, check out the many resources at VEX Professional Development Plus

Last Updated: