Using Switch Blocks to Transition from Blocks to Text-Based Coding in VEXcode IQ (2nd gen)

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).
  • A 2nd Gen IQ Brain.

Diagram illustrating the VEX IQ Blocks programming interface, showcasing various programming blocks and their functions for educational robotics projects.

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

Screenshot of a VEX IQ Blocks tutorial interface, showcasing programming blocks and coding elements designed to help educators and students learn robotics concepts using the VEX IQ platform.

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

Screenshot of a VEX IQ Blocks tutorial interface, showcasing programming blocks used for robotics education, designed to assist beginners in learning coding concepts and building projects with the VEX IQ platform.

Select Convert Block to Switch Block.

Diagram illustrating the VEX IQ Blocks programming interface, showcasing various coding blocks and their functions for educational robotics projects.

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

Diagram illustrating the VEX IQ Blocks programming interface, showcasing various programming blocks and their functions for educational robotics projects.

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

Convert Multiple Blocks to Switch

Screenshot of VEXcode IQ Blocks tutorial interface, showcasing programming blocks and layout for VEX IQ Robotics platform, aimed at educating beginners in robotics and enhancing their programming skills.

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

Screenshot of a Blocks tutorial interface for VEX IQ, showcasing programming elements and options to help beginners learn robotics concepts using VEXcode IQ.

Select Convert Stack to Switch Block.

Screenshot of a VEX IQ Blocks tutorial interface, showcasing programming blocks and coding elements designed for educational purposes in robotics, aimed at beginners and educators using the VEX IQ platform.

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 the VEX IQ Robotics platform's block programming interface, showcasing various programming blocks and their functions for educational robotics projects.

Right-click the Wrapper you want to convert.

Screenshot of a VEX IQ Blocks tutorial interface, showcasing programming blocks and options for building robotics projects, designed to assist educators and students in learning robotics concepts using the VEX IQ platform.

Select Convert Wrapper and Contents to Switch Block.

Diagram illustrating the VEX IQ Blocks programming interface, showcasing various coding blocks and their functions, designed to assist educators and students in learning robotics concepts through visual programming.

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 the VEX IQ Blocks programming interface, showcasing various coding blocks and their functions for educational robotics projects, as part of the Blocks Tutorials section in the VEX IQ knowledge base. Screenshot of VEXcode IQ Blocks tutorial interface, showcasing programming blocks for VEX IQ robotics, designed to assist educators and students in learning robotics concepts and building projects.
Stack blocks Perform main commands. They are shaped to attach above or below other stack blocks. Image illustrating a VEX IQ robotics project, showcasing components and programming elements relevant to the Blocks Tutorials section, designed to aid educators and students in learning robotics concepts and best practices. Screenshot of a VEX IQ Blocks tutorial interface, showcasing programming blocks for educational robotics, designed to assist beginners in learning coding concepts and building projects with the VEX IQ platform.
Boolean blocks Return a condition as either true or false and fits inside any blocks with hexagonal (six-sided) inputs for other blocks. Screenshot of a VEX IQ Blocks tutorial interface, showcasing programming blocks and options for building educational robotics projects, designed for beginners and educators in the VEX IQ ecosystem. Diagram illustrating the VEX IQ Blocks programming interface, showcasing various programming blocks and their functions, designed to assist educators and students in learning robotics concepts through visual programming.
Reporter blocks Report values in the form of numbers and fits inside any blocks with oval inputs for other blocks. Screenshot of a VEX IQ Blocks tutorial interface, showcasing programming blocks and options for building and controlling VEX IQ robots, designed for educational purposes and beginner robotics enthusiasts. Diagram illustrating the VEX IQ Blocks programming interface, showcasing various coding blocks and their functions for educational robotics projects.
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. Screenshot of a VEX IQ Blocks tutorial interface, showcasing programming blocks and options for building and controlling VEX IQ robots, aimed at educating beginners in robotics and enhancing their programming skills. Screenshot of a VEX IQ Blocks Tutorial interface, showcasing programming blocks and options for building robot code, aimed at educational users and beginners in robotics. Diagram illustrating the VEX IQ Blocks programming interface, showcasing various blocks and their functions for educational robotics programming in the VEX IQ platform. Diagram illustrating the VEX IQ Blocks programming interface, showcasing various programming blocks and their functions for educational robotics projects.

 

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: