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.
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.
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.
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.
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.
Choose which numeric variable to use. Numeric variables can also be renamed or deleted.
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.
Change numeric variable#
The Change numeric variable block is used to change a variable by the given value.
Choose which numeric variable to use - the selected variable can also be renamed or deleted.
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.
Boolean variable#
The Boolean variable block is used to report the value of a Boolean variable. Variables are created with global scope by default.
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.
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
.
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.
Choose which boolean variable to use. Boolean variables can also be renamed or deleted.
Choose a 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
.
List item#
The List item block is used to report the value of an item in a list.
Choose which list to use. The list can also be renamed or deleted.
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.
Replace List item#
The Replace List item block is used to update an item in the list to a new value.
Choose which list to use. The list can also be renamed or deleted.
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.
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.
Choose which 2D list to use. The 2D list can also be renamed or deleted.
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.
Length of List#
The Length of List block is used to report the number of items in a list.
Choose which list to use. The 2D list can also be renamed or deleted.
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.
2D List item#
The 2D List item block is used to report the value of an item in a 2D list.
Choose which 2D list to use. The 2D list can also be renamed or deleted.
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.
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 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)
.
Replace 2D List item#
The Replace 2D List item block is used to update an item in the 2D list to a new value.
Choose which 2D list to use. The 2D list can also be renamed or deleted.
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 Robot’s current Y coordinate in the second column of the first row in its moveCoordinates
2D list before stopping.
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.
Choose which 2D list to use. The 2D list can also be renamed or deleted.
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 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)
.
Length of 2D List#
The Length of 2D List block is used to report the number of rows or columns in a 2D list.
Choose which 2D list to use. The 2D list can also be renamed or deleted.
Choose which value to report. The 2D list can report either rows or columns.
The Length of 2D List reporter block fits in blocks that accept circular spaces.
In this example, the Robot will print how many rows there are in the moveCoordinates
2D List.