Switch incorporates familiar elements of block-based programming and integrates text-boxes where text commands can be typed.
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).
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
Right-click on the Block you want to convert to a Switch Block.
Select Convert Block to Switch Block.
The Block will now be switched to a Switch Block with the same parameters.
To turn a Switch Block back into a Block after conversion select the Undo button.
Convert Multiple Blocks to Switch
Right-click the top of the stack you wish to convert to a Switch Block.
Select Convert Stack to Switch Block.
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.
Right-click the Wrapper you want to convert.
Select Convert Wrapper and Contents to Switch Block.
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. | ||
Stack blocks | Perform main commands. They are shaped to attach above or below other stack blocks. | ||
Boolean blocks | Return a condition as either true or false and fits inside any blocks with hexagonal (six-sided) inputs for other blocks. | ||
Reporter blocks | Report values in the form of numbers and fits inside any blocks with oval inputs for other blocks. | ||
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. |