#ADD (add to multi-valued symbol)

Top  Previous  Next

 

#ADD( symbol, expression [, position ] )

#ADD

Adds a new instance to a multi-valued user-defined symbol.

symbol

A multi-valued user-defined symbol.

expression

An expression containing the value to place in the symbol's instance.

position

An integer constant or symbol containing the instance number to add to the symbol. Instance numbering begins with one (1). If the position is greater than the number of previously existing instances plus one, the new instance in appended and no intervening instances are instantiated.

The #ADD statement adds a value to a multi-valued user-defined symbol. An implied #FIX to that symbol's instance occurs. If the symbol is not a multi-valued user-defined symbol then a source generation error is produced.

If the symbol has been declared with the UNIQUE attribute, then the #ADD is a union operation into the existing set of symbol's values. Only one instance of the value being added may exist. Also, the UNIQUE attribute implies the #ADD is a sorted insert into the existing set of symbol's values. After each #ADD, all of the symbol's values will be in sorted order.

If the symbol has been declared without the UNIQUE attribute, duplicate values are allowed. The new value is added to the end of the list and may be a duplicate. If the symbol is a duplicate, then any dependent children instances are inherited.

Example:

#DECLARE(%ProcFilesPrefix),MULTI,UNIQUE   #!Declare unique multi-valued symbol

#FIX(%File,%Primary)                      #!Build list of all file prefiXEs in proc

#ADD(%ProcFilesPrefix,%FilePre)           #!Start with primary file

#FOR(%Secondary)                          #!Then add all secondary files

 #FIX(%File,%Secondary)

#ADD(%ProcFilesPrefix,%FilePre)

#ENDFOR

 

See Also:

#DECLARE

#FIX

#SELECT