Variables#

To put a variable in the Monitor Console, drag and drop its Reporter block to the Monitor Icon on the right side of the screen.

Animation showing a user dragging the 'drive is done?' block from the workspace to the Monitor Console, located at the top right of the screen. The block is moved over the small monitor icon in the top right corner of the coding environment.

Numeric variable#

The Numeric variable block is used to report the numeric value assigned to the variable. Variables are created with global scope by default.

Orange rounded block labeled 'myVariable'.

Use the Set numeric variable block to set or update the numeric value of a variable.

The Numeric Variable reporter block is used in blocks with circular spaces.

Variables are created using the Make a Variable button.

Rectangular button with the text 'Make a Variable'.

In this example, the variable driveLength is set to 500 and used in the Drive for block. This makes the Drive for block move forward for 500 mm.

A coding block sequence starting with 'when started,' followed by 'set driveLength to 500,' and then 'drive forward for driveLength mm.'"

Set numeric variable#

The Set numeric variable block is used to set a numeric variable to a given value. Variables are created with global scope by default.

An orange notched coding block that reads 'set myVariable to 0'.

Choose which numeric variable to use. Numeric variables can also be renamed or deleted.

An orange notched coding block with a dropdown menu open, displaying options to select 'myVariable,' rename the variable, or delete the 'myVariable' variable.

The Set numeric variable block can accept decimals, integers, or numeric blocks.

In this example, the variable driveLength is set to 500 and used in the Drive for block. This makes the Drive for block move forward for 500 mm.

A coding block sequence starting with 'when started,' followed by 'set driveLength to 500,' and then 'drive forward for driveLength mm.'"

Change numeric variable#

The Change numeric variable block is used to change a variable by the given value.

An orange notched coding block with the text 'change myVariable by 1' and a dropdown menu for selecting a variable.

Choose which numeric variable to use - the selected variable can also be renamed or deleted.

An orange notched coding block with the text 'change myVariable by 1' and a dropdown menu expanded below it, showing options to select 'myVariable', rename the variable, or delete the 'myVariable' variable.

The Change numeric variable block can accept decimals, integers, or numeric blocks.

In this example, the variable driveLength is changed by 500 and used in the Drive for block. This makes the Drive for block move forward for 500 mm.

A set of coding blocks with a yellow 'when started' block at the top, followed by an orange notched block that says 'change driveLength by 500,' and below that a blue notched block that says 'drive forward for driveLength mm.'"

Boolean variable#

The Boolean variable block is used to report the value of a Boolean variable. Variables are created with global scope by default.

An orange hexagonal coding block labeled 'myBoolean' in the center.

Use the Set boolean variable block to set or update the value of a boolean variable.

The Boolean variable block reports a true or false value and is used in blocks with hexagonal (six-sided) spaces.

Boolean variables are created using the Make a Boolean button.

A rectangular button with the text 'Make a Boolean' centered inside.

In this example, the driveNow Boolean variable is set to True at the start of the project. This makes the Drivetrain drive forward until the driveNow variable returns False.

A coding block sequence with the following blocks: 'when started', 'set driveNow to true', 'if driveNow then drive forward', and 'stop driving'.

Set Boolean variable#

The Set Boolean variable block is used to set a boolean variable to a given value. Variables are created with global scope by default.

A notched coding block with the text 'set myBoolean to true' with dropdown menus for the variable name and the Boolean value.

Choose which boolean variable to use. Boolean variables can also be renamed or deleted.

A notched coding block with the text 'set myBoolean to true' with dropdown menus for the variable name and Boolean value, and an open dropdown menu displaying options to rename or delete the variable.

Choose a Boolean value.

A notched coding block with the text 'set myBoolean to true' with dropdown menus for the variable name and Boolean value, and an open dropdown menu showing options 'true' (selected) and 'false' for the Boolean value.

The Set Boolean variable block can accept hexagonal (six-sided) shaped blocks.

In this example, the driveNow Boolean variable is set to True at the start of the project. This makes the Drivetrain drive forward until the driveNow variable returns False.

A coding block sequence with the following blocks: 'when started', 'set driveNow to true', 'if driveNow then drive forward', and 'stop driving'.

List item#

The List item block is used to report the value of an item in a list.

A rounded coding block with the text 'item 1 of myList,' where '1' is in a white bubble and 'myList' is in a dropdown menu, indicating the selection of an item from a list.

Choose which list to use. The list can also be renamed or deleted.

A rounded coding block labeled 'item 1 of myList,' with '1' in a white bubble and 'myList' in a dropdown menu. Below the block, an orange dropdown menu is expanded, showing options: 'myList' (selected), 'Rename variable,' and 'Delete the "myList" variable.'"

Enter the number of the item’s position within the list. Here, the second item in list (item 2) is being reported.

The List item block can accept decimals, integers, or numeric blocks.

In this example, the cardinalHeadings list stores the degrees for north, east, south, and west. The Drivetrain turns to face item 3, which is set to 180 degrees.

A coding block sequence starts with 'when started,' followed by 'set cardinalHeadings to 0 90 180 270,' and ends with 'turn to heading item 3 of cardinalHeadings degrees.'"

Replace List item#

The Replace List item block is used to update an item in the list to a new value.

A coding block labeled 'replace item 1 of myList to 0' with notched connections on both ends.

Choose which list to use. The list can also be renamed or deleted.

A coding block labeled 'replace item 1 of myList to 0' with a dropdown menu expanded below, showing options to select 'myList', 'Rename variable', or 'Delete the "myList" variable'.

The Replace List item block can accept decimals, integers, or numeric blocks.

In this example, only item 2 of the cardinalHeadings list is replaced with 90. The Drivetrain will then turn to a heading of 90 degrees.

A coding block sequence with two blocks. The first block says 'when started replace item 2 of cardinalHeadings to 90'. The second block says 'turn to heading item 2 of cardinalHeadings degrees'.

Set List item#

The Set List item block is used to set every item in the list to the entered values. Variables are created with global scope by default.

A coding block that reads 'set myList to 0, 0, 0, 0, 0'.

Choose which 2D list to use. The 2D list can also be renamed or deleted.

A coding block that reads 'set myList to 0, 0, 0, 0, 0' with a dropdown menu open showing options: myList, Rename variable, Delete the 'myList' variable.

The Set List item block can accept decimals, integers, or numeric blocks.

In this example, the cardinalHeadings list stores the degrees for north, east, south, and west. The Drivetrain turns to face item 3, which is set to 180 degrees.

A coding block sequence starting with 'when started,' followed by 'set cardinalHeadings to 0, 90, 180, 270,' and then 'turn to heading item 3 of cardinalHeadings degrees.'"

Length of List#

The Length of List block is used to report the number of items in a list.

A rounded coding block displaying 'length of myList' in orange.

Choose which list to use. The 2D list can also be renamed or deleted.

A rounded coding block displaying 'length of myList' in orange, with a dropdown menu open showing options to select, rename, or delete the 'myList' variable.

The Length of List reporter block fits in blocks that accept circular spaces.

In this example, the length of the cardinalHeadings list will be printed to the Console.

A sequence of coding blocks that starts with 'when started' in yellow, followed by a purple block with the command 'print length of cardinalHeadings' where 'cardinalHeadings' is an orange notched variable.

2D List item#

The 2D List item block is used to report the value of an item in a 2D list.

An orange coding block labeled 'item 1 1 of my2DList,' where 'my2DList' is a notched variable, and two white circular inputs are set to '1' each.

Choose which 2D list to use. The 2D list can also be renamed or deleted.

An orange coding block labeled 'item 1 1 of my2DList,' with a dropdown menu open showing options to select 'my2DList,' rename the variable, or delete the 'my2DList' variable. The block has two white circular inputs, both set to '1,' and the 'my2DList' variable is in a notched shape.

Enter the item’s row (first number) and column (second number) position within the list to be reported. Here, the item in position row 2, column 3 in the 2D list is being reported.

An orange coding block labeled 'item 2 3 of my2DList,' featuring two white circular inputs with values '2' and '3,' and a dropdown menu set to 'my2DList.' The block is in a rounded shape.

The 2D List item block can accept decimals, integers, or numeric blocks.

In this example, the moveCoordinates 2D List is used to store numeric values that relate to positions on the playground. Assuming that the VR Robot starts at the coordinate (0, 0), the Drivetrain uses the items from (5,1) and (5,2) in the 2D List to move to the coordinate (300, 200).

A sequence of coding blocks starting with a 'when started' block. Below it, an orange block sets the 'move_coordinates' list to pairs of numbers (300, 150) and (500, 200). Two blue 'drive forward' blocks follow, each referencing an item from 'move_coordinates' with respective coordinates. The first 'drive forward' block is followed by a 'turn right' block set for 90 degrees.

Replace 2D List item#

The Replace 2D List item block is used to update an item in the 2D list to a new value.

An orange coding block with the text 'replace item 1 1 of my2Dlist to 0,' indicating a command to replace a specific item in a two-dimensional list named 'my2Dlist' with the value 0.

Choose which 2D list to use. The 2D list can also be renamed or deleted.

An orange coding block with the text 'replace item 1 1 of my2Dlist to 0,' with a dropdown menu open showing options for the variable 'my2Dlist,' as well as options to rename or delete the variable.

The Replace 2D List item block can accept decimals, integers, or numeric blocks.

In this example, the Drivetrain will drive forward for 2 seconds. It will record the VR Robot’s current Y coordinate in the second column of the first row in its moveCoordinates 2D list before stopping.

A sequence of coding blocks including 'when started,' 'drive forward,' 'wait 2 seconds,' and 'replace item 1 2 of moveCoordinates to position Y in mm,' followed by 'stop driving' in a blue block.

Set 2D List item#

The Set 2D List item block is used to set every item in the 2D list to the entered values. Variables are created with global scope by default.

An orange coding block labeled 'set move_coordinates to,' with a two-by-two grid containing zeros in the input fields.

Choose which 2D list to use. The 2D list can also be renamed or deleted.

An orange coding block labeled 'set move_coordinates to' with a dropdown menu open below. The dropdown menu shows the options: 'move_coordinates' (selected), 'my2Dlist,' 'Rename variable,' and 'Delete the "move_coordinates" variable.'"

The Set 2D List item block can accept decimals, integers, or numeric blocks.

In this example, the move_coordinates 2D List is used to store numeric values that relate to positions on the playground. Assuming that the VR Robot starts at the coordinate (0, 0), the Drivetrain uses the items from (1,1) and (1,2) in the 2D List to move to the coordinate (300, 150).

A coding sequence with blocks arranged vertically. The first block is a yellow 'when started' block. Below it is an orange block labeled 'set move_coordinates to' with two pairs of coordinates: (300, 150) and (500, 200). Following this, a blue block labeled 'drive forward for item 1 1 of move_coordinates mm' is connected. Next is another blue block labeled 'turn right for 90 degrees.' Finally, another blue block labeled 'drive forward for item 1 2 of move_coordinates mm' completes the sequence.

Length of 2D List#

The Length of 2D List block is used to report the number of rows or columns in a 2D list.

A rounded, orange coding block labeled 'length of my2Dlist rows.'"

Choose which 2D list to use. The 2D list can also be renamed or deleted.

A rounded, orange coding block labeled 'length of my2Dlist rows' with a dropdown menu expanded, showing options 'my2Dlist,' 'Rename variable,' and 'Delete the "my2Dlist" variable.'"

Choose which value to report. The 2D list can report either rows or columns.

A rounded, orange coding block labeled 'length of my2Dlist rows' with the 'rows' dropdown menu expanded, showing options 'rows' and 'columns,' with 'rows' selected.

The Length of 2D List reporter block fits in blocks that accept circular spaces.

In this example, the VR Robot will print how many rows there are in the moveCoordinates 2D List.

A notched, yellow coding block labeled 'when started' connected to a rounded, purple coding block labeled 'print length of moveCoordinates rows,' indicating an action to print the length of the rows in the moveCoordinates list when the program starts.