COBOL Usage is Pointer data item

Another extension of the USAGE clause is to define data items that contain addresses of data or procedures. These are POINTER items:

POINTER A four-byte data item that holds the address of another data item.

PROCEDURE-POINTER A four- or eight-byte data item (depending on the operating system) that contains the address of a program-entry point.

A POINTER data item cannot have a PICTURE clause. The figurative constant NULL (or NULLS) can be used to initialize POINTER and PROCEDURE-POINTER data. No other literal value can be assigned to POINTER data.

In addition to the new data types, vendors implement special registers for use with address data:

ADDRESS OF A register that exists for each record (level 01 or 77) in the Linkage Section of the Data Division. The contents are the address of the data item, for example, ADDRESS OF record.

LENGTH OF A register that contains the length in bytes of the named data item, for example, LENGTH OF identifier.

POINTER data items cannot be used in a MOVE statement.

They are manipulated by an extension of the SET statement that assigns them values:

SET identifier-1 TO ADDRESS OF identifier-2

where identifier-1 is a POINTER data item and identifer-2 is any data item in the Working-Storage Section or Linkage Section. POINTER data items can be used in relation conditions (to test for equality) and as arguments in a CALL statement.

PROCEDURE-POINTER data items can be used as the object of a CALL statement.


One thought on “COBOL Usage is Pointer data item

  1. Pingback: How to Pass COBOL Pointer Data Items in CALL BY REFERENCE – Srinimf

Comments are closed.