COUNT
v1.1
v2.1

Purpose, Argument, Streams, Usage, Examples, Related

Syntax

           ┌─RECORDS─────┐
>>──COUNT──┼─────────────┼───────────────────────────────────────────────────────────>< 
           │ ┌─<───────┐ │
           └─┼─BYTES───┼─┘
             ├─CHARS───┤
             ├─WORDS───┤
             ├─RECORDS─┤
             ├─LINES───┤
             ├─MINline─┤
             ├─MAXline─┤
             ├─ALL─────┤
             └─*───────┘
Purpose

Use the COUNT stage to count bytes, space-delimited character strings or records. You can also use COUNT to return the length of the shortest or longest record. COUNT reads records from its primary input stream and counts each specified item. If its secondary output stream is not connected, COUNT writes a single record containing the count information to its primary output stream and discards the records from its primary input stream. If both its primary and secondary output streams are connected, COUNT copies its primary input stream records to its primary output stream and writes a single record containing the count information to its secondary output stream.

Argument
Streams

Stream
Action
Primary input
COUNT reads records from its primary input stream.
Primary output
If its secondary output stream is not connected, COUNT writes a single record containing the count information to its primary output stream. If its secondary output stream is connected, COUNT copies its primary input stream records to its primary output stream.
Secondary output
If its secondary output stream is connected, COUNT writes a single record containing the count information record to its secondary output stream.

Usage
  1. COUNT delays the count information record until end-of-file is reached. If its secondary output stream is connected, COUNT does not delay the primary output stream records.

  2. If the COUNT stage discovers that its primary output stream is not connected, the COUNT stage ends. If its secondary output stream is connected, the count information record is written to its secondary output stream. The record being processed when the COUNT stage discovers that its primary output stream is not connected is not included in the count information.

  3. COUNT writes only one count information record regardless of the number of input records it reads. The count information record contains information about only those keywords that you specify. If you specify more than one keyword, the counts are returned separated by single spaces.

    If you specify the same keyword or keywords of equivalent function more than once, only one count of that information is returned in the count information record. Regardless of the order in which you specify the keywords, the count information is always returned in the following order:

    bytes words records minimum-record-length maximum-record-length
    

  4. COUNT writes the count information record when it receives an end-of-file condition on either of its input or output streams.

  5. For each item in the count information record, the maximum count is the maximum value that can held by an unsigned integer.

  6. COUNT verifies that its secondary input stream is not connected and then begins execution.
Examples
  1. The following example shows you how to specify the COUNT stage.

    **** Top of file ****
    Address Rxpipe
    'pipe literal /and the clocks were striking thirteen/', '| literal /It was a bright cold day in April/', '| count all', '| console'
    Exit 0 **** End of file ****

    output:
    70 14 2 33 37
Related

CONSOLE, SPECS, VARIABLE

History

Version
Date
Action
Description
Pipelines
1.1
??.??.2025
changed
Application-wide rewrite
2.1
1.0
06.09.2007
created
First version.
1.0