CHOP stage v1.0

Pipelines v2.0

 

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

Home

 

Syntax

 
             _80_____
>>__CHOP__ _|________|______________________________________________________ __________><
          | |_column_|                                                      |
          |            _BEFORE_                                             |
          |_ ______ __|________|__ _____ __ _________ __ _charrange_______ _|
            |_disp_|  |_AFTER__|  |_NOT_|  |_ANYCase_|  |_STRing_ _string_|
                                                        |_ANYof__|

 

Purpose

 

Use the CHOP stage to truncate records selectively. CHOP reads records from its primary input stream, truncates them at the column specified and writes the truncated records to its primary output stream. If its secondary output stream is connected, CHOP writes the truncated portion of each record to its secondary output stream. If you do not specify an operand CHOP truncates records after column 80.

 

Records are truncated relative to occurrences of a specified target. The target can be a range of characters, a character string or a list of characters. You can specify that the records be truncated before or after the specified target.

 

Operands

 

    

column

is an unsigned integer which specifies the column after which CHOP is to truncate the records.

 

    

disp

is an integer which specifies the relative displacement, in number of columns, from the target to the position in the record where truncation is to occur. If you specify:

 

 

disp and BEFORE, truncation occurs before the column that is disp columns to the left of the target.

disp and AFTER, truncation occurs after the column that is disp columns to the right of the target.

-disp and BEFORE, truncation occurs before the column that is disp columns to the right of the target.

-disp and AFTER, truncation occurs after the column that is disp columns to the left of the target.

 

 

BEFORE

causes truncation to take place before the specified target. This is the default.

 

    

AFTER

causes truncation to take place after the specified target. If you specify AFTER with STRING, the records are truncated after the column containing the last character of the first occurrence of the string.

 

    

NOT

negates the way in which CHOP locates the target. If you specify NOT with charrange, the target is any character not within the specified range. If you specify NOT with ANYOF, the target is any character not in the specified list of characters. If you specify NOT with STRING, the target is any column not part of a matching string.

 

    

ANYCase

specifies that charrange or string is compared with the input record in uppercase. In effect this means that a non-case-sensitive comparison is made when selecting a column position at which to truncate the record.

 

    

charrange

is a character range. Truncation occurs when any one of the characters in the range is matched.

 

    

STRing

specifies that the string operand is a literal string of characters to locate. Truncation occurs only when the entire string is matched.

 

    

ANYof

specifies that the string operand is a list of characters to locate. Truncation occurs when any one of the characters in the list is matched.

 

 

string

is a string to locate.

 

Streams used

 

The following streams are used by the CHOP stage:

 

Stream

Action

 

 

Primary input stream

CHOP reads records from its primary input stream.

Primary output stream

After truncating the records read from the primary input stream as specified, CHOP writes the resulting records to its primary output stream.

Secondary output stream

If its secondary output stream is connected, CHOP writes the truncated portion of each record to its secondary output stream.

 

Usage notes

 

     1)

CHOP does not delay the records.

 

     2)

If the CHOP stage discovers that all of its output streams are not connected, the CHOP stage ends.

 

     3)

If the column position at which to truncate is positioned before the first column of an input record, CHOP writes a null record to its primary output stream. If its secondary output stream is connected, the unmodified input record is written to the secondary output stream, otherwise the input record is discarded.

 

     4)

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

 

Examples

 

Truncating records.rex

 

See also

 

Reference the following links for additional information:

 

JOIN, PAD, SPLIT, STRIP, SPECS

 

History of change

 

None.