The data stored by variables can be changed and this is normally done using assignments.
An assignment is formed using the variable's name and an expression denoting the new data it is to store.
The symbol `:=' separates the variable from the expression.
For example, the following code stores the number two in the variable
The left-hand side of the `:=' is the name of the variable to be affected (
x in this case) and the right-hand side is an expression denoting the new value (simply the number two in this case).
x := 2
The following, more complex example uses the value stored in the variable before the assignment as part of the expression for the new data.
The value of the expression on the right-hand side of the `:=' is the value stored in the variable
x plus one.
This value is then stored in
x, over-writing the previous data.
(So, the overall effect is that
x is incremented.)
x := x + 1
This may be clearer in the next example which does not change the data stored in
In fact, this piece of code is just a waste of CPU time, since all it does is look up the value stored in
x and store it back there!
x := x
Go to the Next or Previous section, the Detailed Contents, or the Amiga E Encyclopedia.