TOLABEL stage v1.2

Pipelines v2.1

 

Purpose, Operands, Streams, Usage, Examples, Related

Home

 

Syntax

 

                             ┌─STRing──┐
>>──TOLABel────────────────┼─────────┼───────────────────────────────────────────><
             CASEI(...)─  REGexp──  └─string─┘
             └─ZONE(...)──┘  └─PATtern─┘

 

Purpose

 

Use the TOLABEL stage to select records from the primary input stream. The records selected are determined by the string you specify. The specified target string must begin in the first column of an input record. TOLABEL writes to its primary output stream, if connected, the records that are before the record that begins with the target string.

 

Unless the CASEI or ZONE pre-process option specifies a different column range, string must begin in the first column of an input record. If the secondary output stream is connected, the record that begins with the target string and the following records in the primary input stream are written to the secondary output stream. If the secondary output stream is not connected, the TOLABEL stage stops once the record beginning with the target string has been read.

 

Operands

 

CASEI

perform a non-case-sensitive comparison between the target string and the input record.

 

ZONE

restrict data selection to a specific column, word or field range.

 

STRing

specifies that the string operand is a literal string of characters to locate.

 

REGexp

specifies that the string operand is a regular expression of characters to locate.

 

PATtern

specifies that the string operand is a pattern of characters to locate.

 

string

is a string to locate.

 

If string is not specified, TOLABEL writes any leading null records to its primary output stream. TOLABEL then writes all its remaining input records to its secondary output stream, if it is connected.

 

Streams

 

The following streams are used by the TOLABEL stage:

 

Stream

 

Action

 

 

Primary input stream

TOLABEL reads records from its primary input stream.

Primary output stream

TOLABEL copies input records that do not begin with the specified target string to its primary output stream until a record is found that begins with the target. The record containing the target is not copied to the primary output stream.

Secondary output stream

If its secondary output stream is connected, TOLABEL copies to its secondary output stream all input records not copied to its primary output stream.

 

Usage

 

1.

TOLABEL does not delay the records.

 

2.

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

 

3.

If you specify the ZONE pre-process function, the target string must begin in the first column of the specified column range instead of the first column of the input record. To be selected, the target string must be completely located within the column range; therefore, the length of the target string must be less than or equal to the width of the column range.

 

4.

If the secondary output stream is not connected, the TOLABEL stage stops once the record beginning with the target string has been read.

 

5.

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

 

Examples

 

1.

The following pipeline selects only those records up to, but not including the target string all.

 
   **** Top of file ****
 1 Address Rxpipe
 2
 3 'pipe literal /Now is the time for all good men/',
 4    '| split',
 5    '| tolabel /all/',
 6    '| console'
 7
 8 Exit 0
   **** End of file ****
 
output:
Now
is
the
time
for

 

2.

This example selects all the names in the phone directory file: directory.txt, that begin with the letters A through O and writes them to the output file: phone A-O.txt.

 

directory.txt (input)

 

...|...+....1....+....2....+....3....+....4....

   **** Top of file ****

 1 Name               Age  Phone

 2 A - E

 3 Andrews, Joe       30   555-214-5435

 4 Brown, Sue         28   555-413-3423

 5 F - J

 6 Jones, Fred        50   607-413-8945

 7 K - O

 8 Mills, Bob         23   555-212-2122

 9 P - T

10 Smith, Elaine      45   243-313-4277

11 Smith, Joe         24   234-315-2342

12 Smith, Sue         33   543-314-0087

13 U - Z

14 Zimmer, Jack       39   607-917-8754

   **** End of file ****
 

'pipe < directory.txt | tolabel /P -/ | > phone A-O.txt'

 
phone A-O.txt (output)
 

...|...+....1....+....2....+....3....+....4....

   **** Top of file ****

 1 Name               Age  Phone

 2 A - E

 3 Andrews, Joe       30   555-214-5435

 4 Brown, Sue         28   555-413-3423

 5 F - J

 6 Jones, Fred        50   607-413-8945

 7 K - O

 8 Mills, Bob         23   555-212-2122

   **** End of file ****

 

3.

Sorting a paragraph

 

This example pipeline shows how the FROMLABEL and TOLABEL stages, used in combination; isolate a selection of records which are then sorted and fed back in to the main pipeline stream.

 

Related

 

CASEI, DROP, FROMLABEL, TAKE, ZONE

 

History

 

Version

 

Date

Action

Description

Pipelines

1.2

??.??.2025

changed

Application-wide rewrite.

2.1

1.1

22.03.2008

added

Support for the REGEXP operand; which specifies that the string operand is interpreted as a regular expression.

1.4

1.0

06.09.2007

created

First version.

1.0