You can specify LIST on the last parameter in a parameter-descriptor
list or as an attribute on the last parameter to a procedure.
When the LIST attribute is specified in an entry declaration, it
indicates that zero or more additional arguments can be passed to
that entry. For example, the following declare specifies that vararg must
be invoked with one character varyingz parameter and can be invoked
with any number of other parameters.
When the LIST attribute is specified in the declaration of the
last parameter in a procedure, it indicates that zero or more additional
arguments might have been passed to that procedure.
When the LIST attribute is specified, no descriptors are allowed,
and OPTIONS(NODESCRIPTOR) must be specified on its PROCEDURE statement
and on its corresponding ENTRY declaration.
The address of the first of these additional parameters can be
obtained by the VARGLIST built-in function. This address can be used
to obtain the addresses of any additional parameters as follows:
If the additional parameters to this procedure were passed by
value (BYVALUE), successively incrementing this initial address by
the value returned by the VARGSIZE built-in function will return the
addresses of any additional parameters.
If the additional parameters to this procedure were passed by
reference (BYADDR), successively incrementing this initial address
by the size of a pointer will return the addresses of any additional
parameters.
Example
The following sample program, which
implements a simple version of printf, illustrates
how to use the LIST attribute. The routine varg1 illustrates
how to walk a variable argument list with BYVALUE parameters, and varg2 illustrates
how to walk such a list with BYADDR parameters.