Arrays and structures (and even scalars) are said to be adjustable when array extents (upper and/or lower bounds), string (CHAR, GRAPHIC, WIDECHAR, and BIT) lengths, and/or AREA sizes are not known at compile-time, but are determined at run-time based on program logic. Such data can be declared using a BASED storage class with the REFER option, or by using run-time expressions using BASED or AUTOMATIC storage classes. BASED with REFER is a safer approach and always the correct method if the data defined by such structures is transmitted using I/O statements.
An example of BASED storage with REFER:
dcl (an, cn) fixed bin(31), DCL p ptr; dcl 1 s based(p), 3 x char(4) init('PL/I'), 3 (as,cs) fixed bin(31), 3 array(an refer(as)) char(cn refer(cs)); an = 12; cn = 16; allocate s;
Having the last and the only member adjustable is the most efficient method. The more REFERs you have, the longer the generated code sequences are to manipulate the data. You need to be aware that there is a price to be paid for complex uses, but sometimes it may be worth it.
An example of BASED storage without REFER:
dcl (an, cn) fixed bin(31), DCL p ptr; dcl 1 s based(p), 3 x char(4) init('PL/I'), 3 array(an) char(cn); an = 12; cn = 16; allocate s;
An example of a scalar:
dcl (an) fixed bin(31); an = 12; begin; dcl work char(cn); /* ... */ end;
This use is the most efficient example, mostly because it naturally limits you to a minimal number of simple REFERs.