This is an old revision of the document!
You can think of a variable as a place in the computer's memory to store things. Each variable has a name that must begin with a letter, and may consist of any number of letters, numbers, and dollar signs. They are case sensitive.
a = 99 | Assigns the integer 99 to the variable a |
nom = “Jim” | Assigns the string “Jim” to the variable nom |
print “Say hello to ” + nom | Appends the string in nom the the string “Say hello to ” and displays the result |
a = a + 1 | Takes the value of a and adds one to it, then store the new value back into a |
In previous versions (before 1.99.99.8) Variables that contained strings were required to end with a dollar sign ($). This limitation has been removed and any variable may store any type of value.
Variable Assignment | |||
---|---|---|---|
Operator | Name | Example | Comments |
= | Assign a Number to a Variable | a = 9 | |
= | Assign a String to a Variable | z = “Hola.” | |
= | Assign a Number to a Variable | q$ = 9.9 | |
+= | Add to a Variable | a += 7 | Same as a = a + 7 |
+= | Concatenate to a Variable | f += “.” | Same as f = f + “.” |
-= | Subtract from a Variable | a -= 9 | Same as a = a - 9 |
*= | Multiply a Variable | a *= 2 | Same as a = a * 2 |
/= | Divide a Variable | a /= 8 | Same as a = a / 8 |