Rational Developer for System z
Enterprise PL/I for z/OS, Version 3.8, Language Reference Manual

ALLOCATE statement for controlled variables

The ALLOCATE statement allocates storage for controlled variables, independent of procedure block boundaries. Controlled parameters can also be allocated. The bounds of controlled arrays, the lengths of controlled strings, and the size of controlled areas, as well as their initial values, can be specified in the ALLOCATE statement.

Read syntax diagramSkip visual syntax diagram>>-ALLOCATE----------------------------------------------------->
 
   .-,-------------------------------------------------.
   V                                                   |
>----+-------+--controlled-variable--+---------------+-+--;----->
     '-level-'                       '-| attribute |-'
 
>--| attribute: |----------------------------------------------->
 
>--+-dimension-------------------------------------------+-----><
   +-CHARACTER(length)-----------------------------------+
   +-BIT(length)-----------------------------------------+
   +-GRAPHIC(length)-------------------------------------+
   +-WIDECHAR(length)------------------------------------+
   +-AREA(size)------------------------------------------+
   |          .-,----.                                   |
   |          V      |                                   |
   +-INITIAL(---item-+-)---------------------------------+
   '-INITIAL CALL--entry-reference--+------------------+-'
                                    |   .-,--------.   |
                                    |   V          |   |
                                    '-(---argument-+-)-'
 

Abbreviation: ALLOC

level
Indicates a level number. If no level number is specified, the controlled-variable named must be a level-1 variable.
controlled-variable
Specifies a controlled variable or an element of a controlled major structure. A structure element, other than the major structure, can appear only if the relative structuring of the entire major structure containing the element appears as it is in the DECLARE statement for that structure. In this case, dimension attributes must be specified for all names that are declared with the dimension attribute.

Both controlled and based variables can be allocated in the same statement. For the syntax of based variables, refer to ALLOCATE statement for based variables.

Bounds for arrays, lengths of strings, and sizes of areas (extents) are evaluated at the execution of an ALLOCATE statement:

The dimension attribute must specify the same number of dimensions as declared. The dimension attribute can appear with any of the other attributes and must be the first attribute specified. For example:

  declare X(M) char(N) controlled;
  M = 20;
  N = 5;
  allocate X(25) char(6);

The BIT, CHARACTER, GRAPHIC, WIDECHAR and AREA attributes can appear only for variables having the same attributes, respectively.

Initial values are assigned to a variable upon allocation, if the variable has an INITIAL attribute in either the DECLARE or ALLOCATE statement. Expressions or the CALL option in the INITIAL attribute are evaluated at the point of allocation, using the conditions enabled at the ALLOCATE statement. However, the names are interpreted in the environment of the declaration. If an INITIAL attribute appears in both DECLARE and ALLOCATE statements, the INITIAL attribute in the ALLOCATE statement is used. If initialization involves reference to the variable being allocated, the reference is to the new generation of the variable. For more information on initialization, refer to INITIAL attribute.

Any evaluations performed at the time the ALLOCATE statement is executed (for example, evaluation of expressions in an INITIAL attribute) must not be interdependent.

If storage for the controlled variable is not available, the STORAGE condition is raised.


Terms of use | Feedback

This information center is powered by Eclipse technology. (http://www.eclipse.org)