ZONE pre-process v1.1

Pipelines v2.1

 

Purpose, Operands, Streams, Usage, Examples, Related

Home

 

Syntax

 

>>──stage──ZONE(─┬────────────┬──┬───────┬──┬─────────┬─)──┬──────────┬──────────────><
                 └─inputrange  CASEI─┘  └─REVerse─┘    └─operands─┘

 

Purpose

 

Use the ZONE pre-process function to alter the input records read by the stage from any of its input streams. The ZONE function operates on the input records before they are presented to the stage.

 

There are a number of stages that permit the use of the ZONE function and these are stages that do not perform any translation of their input records. They are purely filter type stages that simply select input records based on some criteria.

 

The ZONE function instructs the manager to extract a substring of the record, determined by the column, word or field range, and optionally; to translate both the stage operands and the content of the input records to uppercase, and present this altered record to the stage when a read-record is requested. The ZONE function does not alter the way in which a stage processes its input and output records, it only alters the format of the record which is presented to the stage. When the stage performs a subsequent write-record request, the manager writes the original unmodified input record to the specified output stream.

 

Operands

 

stage

is the name of a stage that reads records from any of its connected input streams and writes records to any of its output streams. A stage that supports the ZONE function does not delay the records.

 

inputrange

is an integer column, word or field range on which to operate.

 

CASEI

perform a non-case-sensitive selection comparison.

 

REVerse

reverses an input record before it is presented to the stage. Only the characters in the specified range are reversed.

 

operands

are the operands required by the specified stage.

 

Streams

 

None.

 

Usage

 

1.

You cannot specify the ZONE pre-process function with a stage that does not support it.

 

2.

The CASEI function translates input records to uppercase before they are presented to the stage. As such, if the stage searches for a hexadecimal or binary representation of a lowercase character; the stage will not find the character because the input record has already be translated to uppercase, as in the following example:

 

   **** Top of file ****
 1 Address Rxpipe
 2
 3 'pipe lit /aBbCc def ghi/',
 4      '| split',
 5      '| between zone( 3-* casei ) x62 /b/',
 6      '| cons'
 7
 8 Exit 0
   **** End of file ****

 

The lowercase b (x'62') in the literal string is not found because it was translated to an uppercase B before BETWEEN processed its input record.

 

Similarly, if the stage specifies a word or field range with a word or field separator string in hexadecimal or binary format, then the extracted range may not be as expected as the record presented to the stage will have been translated to uppercase.

 

3.

Stages that allow the use of the ZONE function do not delay the records.

 

Examples

 

1.

In the following example, the pipeline specifies only word number 2 as the input location.

 

'pipe lit /a-B-c c-b-A/ | split | fromlab zone( wordsep /-/ w2 casei ) /b/ | cons'
 
output:
a-B-c
c-b-A
 

2.

The following pipeline specifies the third-from-last to the second-from-last columns as the input location.

 

'pipe literal /ABCDE FGHIJ/ | split | tolabel zone( -3;-2 casei ) /hi/ | console'
 
output:

ABCDE

 

3.

The following example reads the file: input.txt and selects records from (and including) one that ends in two hyphens up to (and including) one that ends in a full-stop (period), and writes its output to the file: output.txt.

 

'pipe < input.txt | between zone(-2;-1 reverse) /--/ /./ | > output.txt'

 

When the last character in a record is a full-stop, ZONE reverses the period and the character preceding it so BETWEEN can then find the records that begin with a period.

 

Related

 

BETWEEN, CASEI, FROMLABEL, INSIDE, LOCATE, NLOCATE, OUTSIDE, TOLABEL

 

History

 

Version

 

Date

Action

Description

Pipelines

1.1

28.12.2021

changed

Application-wide rewrite.

2.1

1.0

06.09.2007

created

First version.

1.0