Kednos PL/I for OpenVMS Systems
Reference Manual


Previous Contents Index

3.8.4 Internal Representation of Variable Entry Data

Figure 3-13 shows the internal representation of variable entry data.

Figure 3-13 Variable Entry Data Representation


3.9 File Data

A PL/I file, or file constant, is represented by a file control block. A file control block is an internal data structure maintained by PL/I.

No conversions are defined between file data and other data types. You can assign a file variable only the value of a file constant or the value of another file variable. The only operations that are valid for file data are comparisons for equality (=) and inequality (^=).

This section discusses the following:

3.9.1 File Constants

You declare file constants by using the FILE attribute without the VARIABLE attribute. All file constants are external by default. To define an internal file constant, you must specify the INTERNAL attribute. For example:


DECLARE INFILE FILE; 

This declaration declares a file constant named INFILE whose attributes include EXTERNAL by default.


DECLARE INFILE FILE INTERNAL; 

This declaration specifies that the file constant named INFILE is internal to the block in which it is declared.

If you declare a file constant as EXTERNAL, you must use identical attributes, including ENVIRONMENT attributes, in all blocks that declare the constant. Otherwise, PL/I uses the last set of attributes encountered during compilation and ignores the others.

3.9.2 File Values

Whenever a reference to a file constant is interpreted, the result is a file value. A file value is a pointer to the file control block for the file with which the constant is associated.

PL/I supports the passing of external files, but not internal files, as file value parameters. To pass an internal file, use a file parameter.

3.9.3 File Variables

File variables are variables (including parameters) that take file values. If the VARIABLE attribute is specified with the FILE attribute in a DECLARE statement, the declared identifier is a file variable. You can assign to a file variable either another file variable or a file constant.

A file variable is represented internally as a longword that contains a pointer to a file control block. The value of the file variable, when evaluated, is the address of the file control block for the file with which the variable is currently associated.

The scope of a file variable name can be either internal or external. If neither the EXTERNAL nor the INTERNAL attribute is specified with the file variable, the default is external.

If you declare a file variable implicitly or explicitly as EXTERNAL, you must use identical attributes, including ENVIRONMENT attributes, in all blocks that declare the variable. Otherwise, PL/I uses the last set of attributes encountered during compilation and ignores the others.

You can use the file variable to represent different files during the execution of the PL/I program. For example:


DECLARE F FILE VARIABLE, 
        (A,B) FILE; 
        E = A; 
        CALL READFILE(E); 

The file constant A is assigned to the file variable E. The CALL statement results in the invocation of the entry point READFILE with file A as its parameter.

You can also declare arrays of file variables. The following example shows an array of external file variables:


DECLARE FILELIST(10) FILE VARIABLE, 
        MYFILE FILE VARIABLE; 
 
        MYFILE = FILELIST(3); 

This assignment statement references the third element of the array FILELIST. When the statement is executed, this array element must contain a valid file value.

3.10 Area Data

An area is a region of storage in which based variables can be allocated and freed. You define an area by declaring a variable with the AREA attribute. An area variable can belong to any storage class. Areas provide the following programming capabilities: