COUNT stage v1.0

Pipelines v1.9

 

Purpose, Operands, Streams used, Usage notes, Examples, See also

Home

 

Syntax

 
            _RECORDS_________
>>__COUNT__|_________________|_________________________________________________________><
           |  <____________  |
           |_|__BYTES______|_|
             |__CHARS______|
             |__WORDS______|
             |__RECORDS____|
             |__LINES______|
             |__MINline____|
             |__MAXline____|

 

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.

 

Operands

 

    

BYTES

CHARS

specifies that the number of bytes or characters in the records read from the primary input stream is to be included in the count information record.

 

Note. If the COUNT stage is processing records that originate from < (FILEIN) or IN, then the byte/character count will be less than the actual input file size, as these stages remove carriage control (Line-Feed and Carriage-Return) characters from their input.

 

    

WORDS

specifies that the number of space-delimited character strings in the records read from the primary input stream is to be included in the count information record.

 

    

RECORDS

LINES

specifies that the number of records read from the primary input stream is to be included in the count information record.

 

    

MINline

specifies that the length of the shortest record read from the primary input stream is to be included in the count information record. When there are no input records the value returned is the unsigned integer value _MAX_INT_.

 

    

MAXline

specifies that the length of the longest record read from the primary input stream is to be included in the count information record. When there are no input records the value returned is 0.

 

Streams used

 

The following streams are used by the COUNT stage:

 

Stream

Action

 

 

Primary input stream

COUNT reads records from its primary input stream.

Primary output stream

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 stream

If its secondary output stream is connected, COUNT writes a single record containing the count information record to its secondary output stream.

 

Usage notes

 

     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 operands that you specify. If you specify more than one operand, the counts are returned separated by single spaces.

 

If you specify the same operand or operands 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 operands, 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 unsigned integer value _MAX_INT_.

 

     6)

COUNT verifies that its secondary input stream is not connected and then begins execution.

 

Examples

 

Counting records

 

See also

 

Reference the following link for additional information:

 

SPECS