STORAGE Function

Purpose

Returns a Fixed Bin(31) value that is the number of bytes allocated for the referenced variable.

Syntax

STORAGE(reference) 

Abbreviation(s): STG for STORAGE.

Parameters

reference is a variable.

Description

The STORAGE function returns a Fixed Bin(31) integer that is the number of bytes allocated for the referenced variable. The variable can be a scalar, an array, an array element, a structure, or a member of a structure.

When a reference is made to an individual array element, the value returned is the size of the element of the array and not the size of the entire array. If the variable is a bit string that does not fill an integral number of bytes, the value returned is rounded up to the next byte.

If the variable is of the type character varying it consists of two parts: the text field and the length field. STORAGE returns the declared length of the text field plus two, since the length field always uses two bytes.

If the variable is an area, STORAGE returns the maximum size of the area plus the size of the area header.

For more information on data storage, see your Open PL/I User's Guide.

Examples

DCL A FIXED BIN(15);
      DCL 1 FOO,
            2 AB FIXED BIN(15), 
            2 F001,
               5 A0 CHAR(12),
               5 A2 FIXED BIN(31), 
               5 A1 CHAR(5) VARYING,
            2 ABC CHAR(4);

          PUT SKIP LIST('Should see 2 ->',SIZE (A));
          PUT SKIP LIST('Should see 2 ->',STG (A));
          PUT SKIP LIST('Should see 23 ->',STG (F001)); 
          PUT SKIP;

Restrictions

None.