Show in Frame No Frame
Up Previous Next Title Page Index Contents Search

6.5.2 Variable write and append

To set the value of a global variable, in addition to the simple assignments in 6.5.1 above, you can also use the variable template:
variable 'variableName' write
   'variableValue'
close
For a local variable, use the local template:
local 'variableName' write
   'variableValue'
close
This sets the value of the variable 'variableName' to ‘variableValue’. Similarly to the filename clause, the variable value can be overwritten or appended by using write or append after variable name. For example,
variable 'variableName' append
   'appendedValue'
close
appends the ‘appendedValue’ to the ‘variableValue’, thus after close the new value of variable ‘variableName’ is ‘variableValueappendedValue’.

Similarly to filename..write..close, between filename and write there can be any generator commands, all of whose output goes to building up the variable name to be used. The same applies to forming the variable value.

By forming the variable name at run-time, rather than having it as a fixed element in the generator definition, it is possible to create associative variables. For instance, you can create a variable for each type, and append to it the names of each object of that type, probably with a separator like a newline. You can also add numbers to the end of the variable name, effectively giving you indexed collections: a variable called “Name3” is equivalent to the C syntax “name[3]”.

Show in Frame No Frame
Up Previous Next Title Page Index Contents Search