For Beginners

Lesson 6/18

Using Variables

Do you remember variables? They are like named containers, which can store changing values. A variable named, say, number can be equal to 1, 20, 0.18 or other number you put in it. A variable can also contain text or other types of data.

Run this script:

♥number = 2
♥total = ♥number + ♥number
dialog ♥total

You will see a dialog box displaying 4. In the first line you defined a ♥number variable equal to 2. In the next line you defined a ♥total variable, which is a sum of two ♥number variables. Since 2 and 2 make 4, the dialog command will bring up a dialog box showing 4 as the value of the ♥total variable.

Note: The heart () character is the prefix for all variables in G1ANT.Robot language. You can enter this character by pressing Ctrl+4. It's like $ in PHP language.

In the next lesson you will see why some characters make huge difference for operations on variables.