Variables

A variable is a named container that stores a value. It's like a labeled box where you can put different things inside. You can create variables, change the values they hold (assign new values to them), and use them in your code to perform various operations or make decisions.

create variable

Create a new variable.

Key points:

  • The variable name has to be unique.

  • After the variable is created, you can see three additional blocks in the variables section: set value, change value, and get value.

In the following examples, we assume we have created a variable called “newVar”.

set to

Set a variable to a specified value.

Key points:

  • The variable can be of any type: text, integer, float, vector…

change by

Add the numeric value (e.g. 1) to the variable.

Key points:

  • This function assumes the variable contains a numeric value.

  • If the variable does not have a numeric value (e.g. text, vector), the system auto converts the variable to number 0 when the “change by” block is applied.

get variable Value

Returns the value of a variable by choosing it. For example, you can get the value of the newVar variable here.

Key points:

  • The variable is global. So you can get its value anywhere in the program.

  • The variable needs to be set or changed before you can get value. Otherwise, the return value is undefined.