Automatic storage and attribute
Automatic variables are allocated on entry to the block in which they are declared. They can be reallocated many times during the execution of a program. You control their allocation by your design of the block structure.
Abbreviation: AUTO
AUTOMATIC is the default. Automatic variables are always internal.
B is
invoked, the variables X and Y are
allocated storage. When B terminates, the storage
is released, and the values that X and Y contain
are lost. A: proc;
.
.
.
call B;
B: proc;
declare X,Y auto;
.
.
.
end B;
.
.
.
call B;The storage that is freed is available for allocation to other variables. Thus, whenever a block (procedure or begin) is active, storage is allocated for all variables declared automatic within that block. Whenever a block is inactive, no storage is allocated for the automatic variables in that block. Only one allocation of a particular automatic variable can exist, except for those procedures that are called recursively or by more than one program.
STR has
a length defined by the value of the variable N when
procedure B is invoked. A: proc;
declare N fixed bin;
.
.
.
B: proc;
declare STR char(N);N be initialized either to a restricted
expression or to an initialized static variable. In the following
example, the length allocated is correct for Str1,
but not for Str2. PL/I does
not resolve this type of declaration dependency. dcl N fixed bin (15) init(10),
M fixed bin (15) init(N),
Str1 char(N),
Str2 char(M);