From GridLAB-D Wiki
Jump to: navigation, search

 Proposed for review 

SEQ_ - Sequence global variables Template:NEW30




The SEQ_ global variables provide a mechanism for automatically generating a sequence of integers during the loading process. When the sequence options are referenced, the appropriate action is taken. Sequence actions are as follows.


Initialize the sequence to the value 0 before evaluating the variable.


Increment the sequence value before evaluating the variable.


The following GLM file

#print Initializing: SEQ_A=${SEQ_A:INIT}
#print SEQ_A=${SEQ_A}
#print Incrementing: SEQ_A=${SEQ_A:INC}
#print SEQ_A=${SEQ_A}

outputs the following text

example.glm(1): Initializing: SEQ_A=0
example.glm(2): SEQ_A=0
example.glm(3): Incrementing: SEQ_A=1
example.glm(4): SEQ_A=1


The INC action can be applied to any global of type int32. This means that you can define a global variable of type int32 using the global directive and start with a non-zero value. For example:

global int32 SEQ_B 12;
#print ${SEQ_B:INC}

is acceptable.

Also note that using the SEQ variables in macros may result in unexpected behavior because the macros are processed before certain load functions can be processed. For example, to create multiple objects using sequences, you must use expansions rather than macros, such as

module residential;
global int32 SEQ_A 0;
object house:..10 {
  name "House_${SEQ_A:INC}";
  name `House_{SEQ_A:INC}`;


The SEQ_ globals were introduced in Hassayampa (Version 3.0).

See also