< (FILEIN)
v1.4
v2.1

Purpose, Argument, Streams, Usage, Examples, Related

Syntax

                ┌─ERRor─┐
>>──┬─<──────┬──┼───────┼──┬─────────┬──┬───────┬──┬──────────┬──────────────────────>< 
    └─FILEIN─┘  └─WARn──┘  └─REVerse─┘  └─RECno─┘  └─filename─┘
                                                     (1)
Notes: (1) The filename operand is only allowed if the stage is specified as the first stage in a pipeline.
Purpose

Use the FILEOUT stage to create a disk file or replace the contents of a disk file.

FILEOUT reads records from its primary input stream and writes them to the specified file and to its primary output stream, if it is connected. FILEOUT appends a Line-Feed character to each output record that it writes to the specified file, primary output stream records are written unchanged. If the specified file does not already exist; FILEOUT creates a new file containing the records read from its primary input stream. If the specified file already exists, FILEOUT replaces the contents of the file with the records read from its primary input stream.

If you do not specify a fully qualified path and filename; the FILEOUT stage will create a new file in the current working directory.

Argument
Streams

The following streams are used by the FILEIN stage:

Usage
  1. FILEIN does not delay the records.

  2. If FILEIN discovers that its primary output stream is not connected, the FILEIN stage ends.

  3. When the FILEIN stage opens an input file to read; FILEIN sets a lock on the file; the file cannot be opened by the FILEAPPEND stage or another FILEIN stage until the file is closed and the lock released.

  4. FILEIN determines if an input file exists at the moment the file is opened for reading.

  5. FILEIN splits its input records at Line-Feed characters; discarding both individual and groups of Carriage-Return characters and writes the resulting records to its primary output stream.

  6. FILEIN verifies that its secondary input stream is not connected and then begins execution.
Examples
  1. The following pipeline reads the file: myfile.txt and displays only the third word of each record on the console.

    'pipe < myfile.txt | specs w3 1 | console'
    

  2. This example shows a pipeline which reads an input file in reverse record order. This option may be of particular use when reading a large file, where the records that are to be inspected lie at the end of the file. For example, a running active log-type file.

    Reading a file backwards

  3. This example shows a pipeline that reads a list of files generated by the FILELIST stage command.

    Reading multiple files
Related

CONSOLE, >> (FILEAPPEND), > (FILEOUT), IN, OUT

History

Version
Date
Action
Description
Pipelines
1.4
??.??.2025
changed
Application-wide rewrite
2.1
1.3
23.05.2011
changed
When FILEIN is specified in position where it is not the first stage in the pipeline and the file does not exist or cannot be opened due to an error, the < stage now issues a warning message (instead of an error message) and continues to process its input records.
1.9
1.2
22.04.2008
changed
FILEIN now splits its input at Line-Feed characters; discarding both individual and groups of Carriage-Return characters and writes the resulting records to its primary output stream.
1.5
added
The REVERSE keyword; which specifies that the input file is read in reverse record order.
1.1
09.10.2007
added
Deny write access to an open input file; this prevents the FILEOUT (>) and FILEAPPEND (>>) stages' and other external applications from altering the file while it is being read.
1.2
1.0
06.09.2007
created
First version.
1.0