Using tables (arrays) and pointers
In COBOL, arrays are called tables.
A table
is a set of logically consecutive data items that you define in the DATA
DIVISION
by using the OCCURS
clause.
About this task
Pointers
are data items that contain virtual storage addresses. You define
them either explicitly with the USAGE IS POINTER
clause
in the DATA DIVISION
or implicitly as ADDRESS
OF
special registers.
You can perform the following operations with pointer data items:
- Pass them between
programs by using the
CALL . . . BY REFERENCE
statement. - Move them to other pointers by using the
SET
statement. - Compare them to other pointers for equality by using a relation condition.
- Initialize them to contain an invalid address by
using
VALUE IS NULL
.
Use pointer data items to:
- Accomplish
limited base addressing, particularly if you want to
pass and receive addresses of a record area that is defined with
OCCURS DEPENDING ON
and is therefore variably located. - Handle a chained list.