Global Data Items


PLBCMP Only

 

Global Data Items are data and file definitions that are kept intact across CHAIN instructions. Data and file definitions that are considered Global Data Items are designated by two methods. A single percent sign (%) preceding the field size or following the file type places the item in the Global Data Area and initializes it to the definition in the program. Double percent signs (%%) place the name of the item in the Global Data Area but do not initialize it in any way. Before use, a variable defined with a double percent must be initialized in another module.

Note the following:

  1. Global Data Items are saved in the Global Data Area based on the label for the item. All occurrences of that Global Data Item with that label must be of the same type and, unless the %% form is used, must be the same size, for each chained program.

  2. Global Data Items may be anywhere in a program or loaded module.

  3. Global Data Items may not be defined with a local label (a label starting with the # character).

  4. Global Data Items may be any Data Definition (DIM, INIT, FORM, or INTEGER, including ARRAYS,) any File Definition (AFILE, DBFILE, FILE, IFILE, or PFILE,) or an Object.

  5. If an array data label is placed in the Global Data Area, when initialized, it must have the same number of elements in the array.

  6. Unlike other global data, objects are destroyed during a CHAIN operation except the FONT and COLOR objects.

 

Assume these variables are placed in the Global Data Area. The first program declares them:

 

DATE

DIM

%8

SYSTEM

INIT

%"ACCTSPAY"

COUNT

FORM

%4

LOOP

INTEGER

%1

TFILE

FILE

%

 

then successive programs would declare them (in any order) as follows:

 

LOOP

INTEGER

%1

SYSTEM

DIM

%8

COUNT

FORM

%4

DATE

DIM

%8

TFILE

FILE

%

 

or:

 

TFILE

FILE

%%

SYSTEM

DIM

%%

COUNT

FORM

%%

DATE

DIM

%%

LOOP

INTEGER

%%

 

Using this example, the variables would retain the values set by the previous program (that could change them if necessary). They are not initialized and blank filled by the subsequent program. They must be explicitly changed in the next program.

 

 

See Also: Common Data Items, Data Definitions

 



PL/B Language Reference Common Data Items Arrays