next up previous contents index
Next: 13.4 Writing blocks using Up: 13. Programming With Variables Previous: 13.2 Units of Variables   Contents   Index

13.3 Changing Variable Values

The variable assignment operator allows you to change the value of a variable while a gcode program is running. Any reference to a variable name followed by an equals sign and a number or an expression in brackets [ ] will assign that number to the named variable.

#1002 = [#1000 + #1001]

In the case of the previous line, #1002 takes on the value of the sum of two other variables. Variables can be assigned any values that can be computed within a program.

One interesting case of assignment comes from the fact that you can assign a variable it's own value so incrementing is permitted by the interpreter.

#1000 = [#1000 + 1]

If you increment or change a variable while a program is running it will hold its new value for the next run of the same program. It will continue to hold the last value when you start a different program.


next up previous contents index
Next: 13.4 Writing blocks using Up: 13. Programming With Variables Previous: 13.2 Units of Variables   Contents   Index
root 2003-05-26