Rational Developer for System z
Enterprise PL/I for z/OS, Version 3.8, Language Reference Manual

FILE attribute

The FILE attribute specifies that the associated name is a file constant or file variable.

Read syntax diagramSkip visual syntax diagram>>-FILE--------------------------------------------------------><
 

The FILE attribute can be implied for a file constant by any of the file description attributes. A name can be contextually declared as a file constant through its appearance in the FILE option of any input or output statement, or in an ON statement for any input/output condition.

File constant

Each data set processed by a PL/I program must be associated with a file constant.

The individual characteristics of each file constant are described with file description attributes. These attributes fall into two categories: alternative attributes and additive attributes.

An alternative attribute is one that is chosen from a group of attributes. If no explicit or implied attribute is given for one of the alternatives in a group and if one of the alternatives is required, a default attribute is used.

Table 29 lists the PL/I alternative file attributes.

Table 29. Alternative file attributes
Group Type
Alternative Attributes
Default Attribute
Usage
STREAM or RECORD
STREAM
Function
INPUT or OUTPUT or UPDATE
INPUT
Access
SEQUENTIAL or DIRECT
SEQUENTIAL
Buffering
BUFFERED or UNBUFFERED
BUFFERED
(for SEQUENTIAL files);

UNBUFFERED (for DIRECT files)
Scope
EXTERNAL or INTERNAL
EXTERNAL

An additive attribute is one that must be stated explicitly or is implied by another explicitly stated attribute. The additive attributes are ENVIRONMENT, KEYED and PRINT. The additive attribute KEYED is implied by the DIRECT attribute. The additive attribute PRINT can be implied by the output file name SYSPRINT.

Table 30 shows the attributes that apply to each type of data transmission.

Table 30. Attributes by data transmission type
Type of transmission Attribute
Stream-oriented ENVIRONMENT
  INPUT and OUTPUT
  PRINT
  STREAM
Record-oriented BUFFERED and UNBUFFERED
  DIRECT and SEQUENTIAL
  ENVIRONMENT
  INPUT, OUTPUT, and UPDATE
  KEYED
  RECORD

Table 31 shows the valid combinations of file attributes.

Table 31. Attributes of PL/I file declarations
File
Type
S
T
R
E
A
M
RECORD
Legend:
I
Must be specified or implied  
D
Default
O
Optional
S
Must be specified
-
Invalid
SEQUENTIAL
DIRECT
Data
Set
Organization
C
o
n
s
e
c
u
t
i
v
e
C
o
n
s
e
c
u
t
i
v
e
R
e
l
a
t
i
v
e
I
n
d
e
x
e
d
R
e
l
a
t
i
v
e
I
n
d
e
x
e
d
File Attributes
Attributes Implied
FILE
I
I
I
I
I
I
INPUT1
D
D
D
D
D
D
FILE
OUTPUT
O
O
O
O
O
O
FILE
ENVIRONMENT
O
O
O
O
O
O
FILE
STREAM
D
-
-
-
-
-
FILE
PRINT1
O
-
-
-
-
-
FILE STREAM OUTPUT
RECORD
-
I
I
I
I
I
FILE
UPDATE
-
O
O
O
O
O
FILE RECORD
SEQUENTIAL
-
D
D
D
-
-
FILE RECORD
KEYED2
-
-
O
O
I
I
FILE RECORD
DIRECT
-
-
-
-
S
S
FILE RECORD KEYED
Notes:
  • 1 A file with the INPUT attribute cannot have the PRINT attribute
  • 2 KEYED is required for indexed and relative output

Scope is discussed in Scope of declarations.

The FILE attribute can be implied for a file constant by any of the file description attributes discussed in this chapter. A name can be contextually declared as a file constant through its appearance in the FILE option of any input or output statement, or in an ON statement for any input/output condition.

In the following example, the name Master is declared as a file constant:

  declare Master file;

File variable

A file variable has the attributes FILE and VARIABLE. It cannot have any of the file constant description attributes. File constants can be assigned to file variables. After assignment, a reference to the file variable has the same significance as a reference to the assigned file constant.

The value of a file variable can be transmitted by record-oriented transmission statements. The value of the file variable on the data set might not be valid after transmission.

The VARIABLE attribute is implied under the circumstances described in VARIABLE attribute.

In the following declaration Account is declared as a file variable, and Acct1 and Acct2 are declared as file constants. The file constants can subsequently be assigned to the file variable.

  declare Account file variable,
    Acct1 file,
    Acc2 file;

For syntax information, refer to VARIABLE attribute.

Specifying a file reference

A file reference can be a file constant, a file variable, or a function reference which returns a value with the FILE attribute. It can be used in the following ways:

On-units can be established for a file constant through a file variable that represents its value (see ON-units for file variables). In the following example, the statements labelled L1 and L2 both specify null ON-units for the same file.

  dcl F file,
      G file variable;
      G=F;
  L1:  on endfile(G);
  L2:  on endfile(F);

Terms of use | Feedback

This information center is powered by Eclipse technology. (http://www.eclipse.org)