Part 8 — File and I/O Operations¶
8.1 I/O Overview¶
The Heirloom PL/I Runtime supports both stream-oriented and record-oriented I/O, preserving the semantics of mainframe PL/I file processing.
8.1.1 I/O Architecture¶
┌─────────────────────────────────────────────┐
│ PL/I I/O Layer │
│ │
│ ┌─────────────────┐ ┌─────────────────┐ │
│ │ Stream I/O │ │ Record I/O │ │
│ │ (PLIStream) │ │ (PLIRecord) │ │
│ │ │ │ │ │
│ │ GET LIST │ │ READ │ │
│ │ GET EDIT │ │ WRITE │ │
│ │ GET DATA │ │ REWRITE │ │
│ │ PUT LIST │ │ LOCATE │ │
│ │ PUT EDIT │ │ NOTE │ │
│ │ PUT DATA │ │ │ │
│ │ PUT STRING │ │ ISAM support │ │
│ │ GET STRING │ │ Sequential │ │
│ │ │ │ Direct/random │ │
│ └────────┬────────┘ └────────┬────────┘ │
│ │ │ │
│ └────────┬───────────┘ │
│ ▼ │
│ ┌─────────────────┐ │
│ │ PLIFile Factory │ │
│ │ (IPLIFile) │ │
│ │ │ │
│ │ DD name mapping │ │
│ │ Env. variables │ │
│ │ Properties │ │
│ └─────────────────┘ │
└─────────────────────────────────────────────┘
8.2 File Declaration and Attributes¶
8.2.1 FILE Declaration¶
8.2.2 File Attributes¶
| Attribute | Description |
|---|---|
| RECORD / STREAM | Record-oriented or stream-oriented I/O |
| INPUT / OUTPUT / UPDATE | File access direction |
| SEQUENTIAL / DIRECT | Access method |
| BUFFERED / UNBUFFERED | Buffering mode |
| Print file (with page control) | |
| KEYED | Keyed access (for ISAM/VSAM files) |
| ENVIRONMENT(...) | File environment specifications |
8.3 File Operations¶
8.3.1 OPEN Statement¶
Open a file with specified attributes.
8.3.2 CLOSE Statement¶
Close one or more open files.
8.3.3 DD Name Resolution¶
Files are resolved via environment variables in the following order: 1. DD_<filename> environment variable 2. DDNAME_<filename> environment variable 3. Property file configuration 4. Direct file path
8.4 Stream I/O¶
8.4.1 GET LIST¶
Read data items separated by blanks or commas.
8.4.2 GET EDIT¶
Read data items with format-directed editing.
8.4.3 GET DATA¶
Read self-identifying data (name=value pairs).
8.4.4 PUT LIST¶
Write data items in default format.
8.4.5 PUT EDIT¶
Write data items with format-directed editing.
Format items: A(w), F(w,d), E(w,d,s), B(w), P'picture', X(n), SKIP(n), COLUMN(n), PAGE, LINE(n)
8.4.6 PUT DATA¶
Write self-identifying data.
8.4.7 PUT STRING / GET STRING¶
In-memory stream I/O using character strings as source/target.
8.5 Record I/O¶
8.5.1 READ Statement¶
Read a record from a file.
Options: FILE, INTO, SET, KEY, KEYTO, IGNORE
8.5.2 WRITE Statement¶
Write a record to a file.
Options: FILE, FROM, KEYFROM
8.5.3 REWRITE Statement¶
Rewrite a record in place.
Options: FILE, FROM, KEY
8.5.4 LOCATE Statement¶
Locate-mode output (allocate buffer, write on next I/O).
8.5.5 NOTE Statement¶
Get the current file position.
8.5.6 FLUSH Statement¶
Flush output buffers.
8.6 Print File Support¶
8.6.1 PRINT Attribute¶
- SYSPRINT as default print file
- Page control (PAGE, SKIP, LINE, COLUMN)
- Automatic pagination
8.6.2 ENDPAGE Condition¶
Raised when output reaches the end of a page.