CHOP
v1.1
v2.1

Purpose, Argument, Streams, Usage, Examples, Related

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. By default; if you do not specify an argument 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.

Argument
Streams

Stream
Action
Primary input
ARRAY reads records from its primary input stream, if it is connected and writes them to the specified ooRexx array.
Primary output
ARRAY writes records to its primary output stream, if it is connected.

Usage
  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

The following examples of the CHOP command use a range of options including the ANYof, BEFORE and AFTER keywords.

  1. 'pipe literal /1234567890/ | chop 5 | console'
    output:
    12345

  2. 'pipe literal /abcaabccabcaa/ | chop str /ccab/ | console'
    output:
    abcaab

  3. 'pipe literal /abcaabccabcaa/ | chop anyof /c / | console'
    output:
    ab

  4. 'pipe literal /abcdefghijklmn/ | chop -2 after str /j/ | console'
    output:
    abcdefgh

  5. 'pipe literal /abcdefghijklmn/ | chop -2 before str /j/ | console'
    output:
    abcdefghijk

  6. 'pipe literal /1234567890/ | chop 0 | count bytes | cons'
    output:
    0
Related

JOIN, PAD, SPECS, SPLIT, STRIP

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