Input and Output:

XPL provides a unique model for I/O. Files and streams do not have to be explicitly opened and closed; they are opened at first use and closed at program termination.
 
String input.
XPL uses the input  function for string input. Base XPL supports four input streams, identified by input(0) ... input(3). Each reference to input(k)  returns the next record (line) from stream k. Conventionally, input(0)  and input(1)  represent the default system input stream (SYSIN or stdin) and input(2)  and input(3)  represent auxiliary input streams. The details of how streams are associated with system resources are operating-system-dependent.
 
String output.
XPL uses the output  psuedovariable for string output. Base XPL supports four output streams, identified by output(0) ... output(3). Each assignment to output(k) writes the next record (line) to stream k. Conventionally, output(0) and output(1) represent the default system output stream (SYSPRINT or stdout), output(2) represents a "card punch" (SYSPUNCH), and output(3)  represents an auxiliary output stream. The details of how streams are associated with system resources are operating-system-dependent. Lines written to output(0)  and output(1)  will normally appear intermixed on the external media.

Output(0)  and output(1)  differ in one important respect: lines written to output(0)  will be single-spaced. Lines written to output(1)  are assumed to have a "forms-control" character in the first byte. Common forms-control codes are:
spaceSingle-space this line
'0'Skip two lines before printing current line
'-'Skip three lines before printing current line
'+'Suppress space before printing current line (overprint)
'1'Skip to top-of-form before printing current line (page eject)

The details of this may be operating-system-dependent.
See ANSI draft dpANS X3.78: Proposed American National Standard Representation of Vertical Carriage Positioning Characters in Information Interchange, level 1.
 
Direct-access I/O.
XPL provides file(i) (i=0..3) for direct (random) access input and output. All direct-access I/O is performed in blocks of fixed-length. The size of the block is operating-system and installation-dependent. To read block from file(k), assign the value of the function file(k,n)  to a character array. To write block to file(k), assign the value of a character array to file(k,n). The size of the array must be equal to the size of the block, or the results are undefined and likely unpleasant. Details of associating XPL "files" with system resources are operating-system-dependent.
 
Examples:

  output = message || t || '.';
  output(1) = '1'; /* Page-eject */
  buffer = input;
  file(stringfile,cursblk) = strings;
  code = file(codefile,cursblk);