# Variables

We use the term variable as it is used in mathematics and other programming languages: a named value that can be changed (varied). Variables can be created in different ways.

- Some blocks like **count with** and **for each** use a variable and define its values. A traditional IT term for such variables is loop variables.
- User-defined functions (also called “procedures” can define inputs, which can be used to create variables that can only be used in this function. Such variables are traditionally referred to as “parameters” or “arguments.”
- Users can change variables at any time using the **set** block. These are traditionally called “global variables.” They can be used anywhere in the code of ROBO Pro Coding.

#### Drop down menu

When you click the drop down symbol (small triangle) for a variable, the following menu appears:

[![Bild1_e.PNG](https://docs.fischertechnik-cloud.com/uploads/images/gallery/2021-12/scaled-1680-/Slabild1-e.PNG)](https://docs.fischertechnik-cloud.com/uploads/images/gallery/2021-12/Slabild1-e.PNG)

The menu offers the following options.

- display the names of all available variables defined in the program.
- “rename variable ...,” e.g. change the name of this variable wherever it appears in the program (choosing this option will open a query asking for the new name)
- “delete variable ...,” e.g. Delete all blocks that refer to this variable, wherever they are in the program.

### Blocks

#### Set

The **set** block assigns a value to a variable, and creates the variable if it does not yet exist. For example, this is how to set the value for the variable **age** to 12:

[![Bild2_e.PNG](https://docs.fischertechnik-cloud.com/uploads/images/gallery/2021-12/scaled-1680-/mKgbild2-e.PNG)](https://docs.fischertechnik-cloud.com/uploads/images/gallery/2021-12/mKgbild2-e.PNG)

#### Call

The **call** block delivers a variable saved in a variable without changing it:

[![Bild3.PNG](https://docs.fischertechnik-cloud.com/uploads/images/gallery/2021-12/scaled-1680-/BgEbild3.PNG)](https://docs.fischertechnik-cloud.com/uploads/images/gallery/2021-12/BgEbild3.PNG)

It is possible to write a program containing a **call** block without a relevant set block, but this is a bad idea.

#### Change

The **change** block inserts a number for a variable.

[![Bild4_e.PNG](https://docs.fischertechnik-cloud.com/uploads/images/gallery/2021-12/scaled-1680-/Zqobild4-e.PNG)](https://docs.fischertechnik-cloud.com/uploads/images/gallery/2021-12/Zqobild4-e.PNG)

The **change** block is an abbreviation for the following construct:

[![Bild5_e.PNG](https://docs.fischertechnik-cloud.com/uploads/images/gallery/2021-12/scaled-1680-/2lGbild5-e.PNG)](https://docs.fischertechnik-cloud.com/uploads/images/gallery/2021-12/2lGbild5-e.PNG)

#### Example

Look at the following example code:

[![Bild6_e.PNG](https://docs.fischertechnik-cloud.com/uploads/images/gallery/2021-12/scaled-1680-/6I7bild6-e.PNG)](https://docs.fischertechnik-cloud.com/uploads/images/gallery/2021-12/6I7bild6-e.PNG)

The first row of blocks creates a variable named **age** and **sets** its initial value to the number 12. The second row of blocks **calls** up the value 12, adds 1 to it, and saves the total (13) in the variables. In the last line, the following message appears: “Congratulations! You are now 13.”