ILE COBOL Programmer's Guide


Initializing Pointers Using the NULL Figurative Constant

The NULL figurative constant represents a value used to indicate that data items defined with USAGE IS POINTER, USAGE IS PROCEDURE-POINTER, ADDRESS OF, or the ADDRESS OF special register do not contain a valid address. For example:

 WORKING-STORAGE SECTION.
  77 APTR  USAGE POINTER VALUE NULL.
 PROCEDURE DIVISION.
     IF APTR = NULL THEN
        DISPLAY 'APTR IS NULL'
     END-IF.

In the above example, pointer APTR is set to NULL in the Working-Storage section. The comparison in the procedure division will be true and the display statement is executed.

On the AS/400 system, the initial value of a pointer data item or procedure-pointer data item with or without a VALUE clause of NULL, equals NULL.


[ Top of Page | Previous Page | Next Page | Table of Contents | Index ]