Common Data Items


ANSI

 

Common Data Items are data or file definitions that are passed unchanged between programs. All data definitions are initialized as defined. Common data and file definitions are designated by an asterisk (*) preceding the field size or following the file type. The first program loaded initializes the defined Common Data Items.

Note the following:

  1. Common Data Items must be of the same type and size and reside in the same position at the start of the User Data Area for each chained program. Common data size may be increased or decreased in subsequent programs but the Common Data Items must always remain in alignment.

  2. Common Data Items must be contiguous and precede all other data or file definitions.

  3. Failure to follow rules one and two may cause unpredictable results.

  4. Common Data is not propagated to LOADMOD modules and does not require data alignment. Any calling routine variables needed in a LOADMOD module should be declared as GLOBAL or passed as arguments to the ROUTINE or PROCEDURE in the module.

  5. Common Data Items may be any Data Definition (DIM, INIT, FORM, or INTEGER, including ARRAYS) or the File Definitions AFILE, FILE, or IFILE.

  6. The Common Data Items are a part of the Program Data Area and are included in any size calculations for the Data Area.

  7. Three Data Definition Labels are reserved as Common Data Items (and in the Global Data Area for PLBCMP) for every program:

 

Example: ( For 9.1D PLBCMP )

 

 

%IFDEF

S$CMPVER$

 

ICMPVER

INTEGER

2,S$CMPVER$

Program checks INTEGER value!

 

%IF

S$CMPVER$ >= 0x91D

 

 

DISPLAY

"DO 9.1D CODE!"

9.1D or later compiler used!

 

%ENDIF

 

 

 

%ELSE

 

 

 

DISPLAY

"DO PRE-9.1D CODE!"

Pre 9.1D compiler used!

 

%ENDIF

 

 

 

 

Assume these variables are passed between programs. The first program declares them:

 

DATE

DIM

8

SYSTEM

INIT

"ACCTSPAY"

COUNT

FORM

4

LOOP

INTEGER

1

TEMPFILE

FILE

 

 

then all successive programs would declare them as follows:

 

DATE

DIM

*8

SYSTEM

DIM

*8

COUNT

FORM

*4

LOOP

INTEGER

*1

TFILE

FILE

*

 

Using this example, the variables would retain the values set by the previous program. They are not re-initialized and blank filled by this program.

 

 

See Also: Global Data Items, Data Definitions

 



PL/B Language Reference Data Definitions Global Data Items