CONSOLE
v1.3
v2.1

Purpose, Argument, Streams, Usage, Examples, Related

Syntax

(1)
>>──┬─CONSole──┬──┬─────────────┬────────────────────────────────────────────────────>< 
    ├─SCReen───┤  └─STOPstring─┘
    └─TERMinal─┘
(2) STOP ?
Notes: (1) May be specified only when CONSOLE is the first stage of a pipeline. (2) Display the CONSOLE prompt and STOP string.

(1)
>>────CONSole──────────────────────┬─────────────────────────┬───────────────────────>< 
                                   └─prefixstr─┬───────────┬─┘
                                             └─suffixstr─┘
Notes: (1) May be specified only when CONSOLE is not the first stage of a pipeline.
Purpose

Use the CONSOLE stage to read lines from the keyboard or write lines to the console.

  1. When CONSOLE is the first stage of the first pipeline; CONSOLE reads records from the keyboard and writes them to its primary output stream.

    CONSOLE stops reading when:

    Only a single active CONSOLE stage (from the moment it is initialised until it completes processing and ends) can read from the keyboard at any one time. You may specify multiple CONSOLE stages that read from the keyboard, including those in a CALLPIPE chain, but only a single active instance can have exclusive access to the keyboard for input. If more than one CONSOLE stage attempts to secure exclusive access to the keyboard for input; then an error is raised and the pipeline ends.

  2. When CONSOLE is not the first stage of a pipeline; CONSOLE reads records from its primary input stream and writes them to the console and to its primary output stream, if it is connected. CONSOLE appends a Line-Feed character to each output record that it writes to the console, primary output stream records are written unchanged.

Argument
Streams

Stream
Action
Primary input
When CONSOLE is not the first stage of the pipeline, CONSOLE reads records from its primary input stream.
Primary output
When CONSOLE is the first stage of the first pipeline, CONSOLE writes the records it reads from the keyboard to its primary output stream.

Usage
  1. CONSOLE does not delay the records.

  2. When CONSOLE is the first stage of the first pipeline and it discovers that its primary output stream is not connected, the CONSOLE stage ends.

  3. The following example shows how the CONSOLE stage reads interactively from the keyboard; writing each of the input records to the output file: keyboard.txt.

    **** Top of file ****
    Address Rxpipe
    'pipe cons stop /eof/', '| xlate', '| specs recno 1 1-* nw', '| console', '| > keyboard.txt'
    Exit 0 **** End of file ****

    console:
    CONSOLE(0): 'eof' to stop. CONSOLE(0): ? one 1 ONE CONSOLE(0): ? flew over 2 FLEW OVER CONSOLE(0): ? the cuckoos 3 THE CUCKOO'S CONSOLE(0): ? nest 4 NEST CONSOLE(0): ? eof

    keyboard.txt
    
    ...|...+....1....+....2....+....3....+....4....
       **** Top of file ****
     1          1 ONE
     2          2 FLEW OVER
     3          3 THE CUCKOO'S
     4          4 NEST
       **** End of file ****
    

  4. CONSOLE may stop reading from the keyboard before the condition specified in the argument is satisfied. If a stage that reads records which flow out of the CONSOLE stage, ends or disconnects its input stream, the CONSOLE stage ends; as in the following example:

    The first CONSOLE stage stops reading from the keyboard after the second line of data or a null has been entered. (The TAKE stage reads exactly 2 records and then disconnects is primary input stream; causing the primary output stream of the CONSOLE stage to become disconnected; which terminates the stage).

    **** Top of file ****
    Address Rxpipe
    'pipe console', '| take 2', '| console' Exit 0 **** End of file ****

  5. When the pipe TRACE ON option is specified (or the pipeline has inherited the TRACE ON setting through the CALLPIPE stage command); the CONSOLE stage encloses it's console output in angle brackets – prefixed with the CONSOLE stage name. For example:

    'pipe (trace on) literal /A literal string/ | console /"/ /"/'
    output:
    CONSOLE: >A literal string<

    However; the CONSOLE stage only uses this output format when writing a record to the console; records that are written to the primary output stream are written without modification.

  6. CONSOLE verifies that its secondary input and output streams are not connected and then begins execution.
Examples

See: Usage.

Related

IN, OUT, OUTPUT

History

Version
Date
Action
Description
Pipelines
1.3
??.??.2025
changed
Application-wide rewrite
2.1
1.2
23.05.2011
added
When the pipe TRACE ON option is specified (or the pipeline has inherited the TRACE ON setting through the CALLPIPE stage command); the CONSOLE stage encloses it's console output in angle brackets – prefixed with the CONSOLE stage name.
1.9
1.1
22.04.2008
changed
Carriage-Return control characters are now discarded by the string operand.
1.5
1.0
06.09.2007
created
First version.
1.0