Next: Dynamic Text, Previous: Named Definitions, Up: Definitions File [Contents][Index]
In AutoGen, every name is implicitly an array of values. When assigning values, they are usually implicitly assigned to the next highest slot. They can also be specified explicitly:
mumble[9] = stumble; mumble[0] = grumble;
If, subsequently, you assign a value to mumble
without an
index, its index will be 10
, not 1
.
If indexes are specified, they must not cause conflicts.
#define
-d names may also be used for index values.
This is equivalent to the above:
#define FIRST 0 #define LAST 9 mumble[LAST] = stumble; mumble[FIRST] = grumble;
All values in a range do not have to be filled in. If you leave gaps, then you will have a sparse array. This is fine (see FOR - Emit a template block multiple times). You have your choice of iterating over all the defined values, or iterating over a range of slots. This:
[+ FOR mumble +][+ ENDFOR +]
iterates over all and only the defined entries, whereas this:
[+ FOR mumble (for-by 1) +][+ ENDFOR +]
will iterate over all 10 "slots". Your template will likely have to contain something like this:
[+ IF (exist? (sprintf "mumble[%d]" (for-index))) +]
or else "mumble" will have to be a compound value that, say, always contains a "grumble" value:
[+ IF (exist? "grumble") +]