PAD stage v1.1

Pipelines v2.1

 

Complete formatting the examples. Including descriptions

 

Purpose, Operands, Streams, Usage, Examples, Related

Home

 

Syntax

 

         ┌─Right─┐          ┌─SPACE─┐
>>──PAD──┼───────┼──length──┼───────┼────────────────────────────────────────────────><
         └─Left──┘          └─char──┘

 

Purpose

 

Use the PAD stage to extend records with one or more specified characters or spaces. You can extend a record on the left or right. PAD reads records from its primary input stream; extends the records, and writes the resulting records to its primary output stream.

 

Operands

 

Right

specifies that records are padded on the right. This is the default.

 

Left

specifies that records are padded on the left.

 

length

is an unsigned integer which specifies the length to which PAD is to extend records. If the length of a record is less than length, PAD extends the record with the number of characters needed to make the output record length characters in length. If the length of the record is greater than or equal to length, PAD copies the record unchanged to its primary output stream.

 

char

is the character used to extend output records.

 

Streams used

 

The following streams are used by the PAD stage:

 

Stream

 

Action

 

 

Primary input stream

PAD reads records from its primary input stream.

Primary output stream

After extending the records read from its primary input stream, PAD writes the resulting records to its primary output stream.

 

Usage notes

 

1.

PAD does not delay the records.

 

2.

If the PAD stage discovers that its primary output stream is not connected, the PAD stage ends.

 

3.

PAD verifies that its secondary input and output streams are not connected and then begins execution.

 

Examples

 

1.

The CMS QUERY SEARCH command returns information similar to the following:

DAC191  191   A    R/W

PROD    196   B/A  R/O

CMSB03  190   S    R/O

19EESA  19E   Y/S  R/O

To create a file PAD OUTPUT shown in Figure 131, that contains the records extended with periods on both the left and right sides of the records, use an exec similar to the following:

/* PADQSRCH EXEC */

'pipe cms QUERY SEARCH',          /* get QUERY SEARCH output   */

'| pad left 35 .',                /* pad with periods on left  */

'| pad 50 .',                     /* pad with periods on right */

'| > PAD OUTPUT A'                /* write records to the file */

cms QUERY SEARCH writes the response from the QUERY SEARCH command to the primary output stream.

pad left 35 . reads the records written by the CMS stage, extends them to a length of 35, and pads them on the left with periods.

pad 50 . extends the records to a length of 50 and pads on the right with periods.

> PAD OUTPUT A writes the records to file PAD OUTPUT A.

Figure 131. PAD Stage Example: Output File Contents

 PAD      OUTPUT   A1  V 80  Trunc=80 Size=4 Line=0 Col=1 Alt=0

 

 

 

 

      |...+....1....+....2....+....3....+....4....+....5....+....6....+....7...

===== * * * Top of File * * *

===== .............DAC191  191   A    R/W...............

===== .............PROD    196   B/A  R/O...............

===== .............CMSB03  190   S    R/O...............

===== .............19EESA  19E   Y/S  R/O...............

===== * * * End of File * * *

 

 

2.

The following example shows how you might format a file so that every record is of the same length. The PAD stage ensures that records are at least 80 characters in length and the CHOP stage, which immediately follows; truncates any records that are longer than 80 characters.

 

'pipe < myfile.txt | pad 80 | chop 80 | > myfile.txt'

 

3.

Padding records

 

????

 

4.

Padding to the longest record length

 

????

 

5.

Positioning text

 

????

 

 

Related

 

CHOP, SPLIT, STRIP

 

History

 

Version

 

Date

Action

Description

Pipelines

1.1

27.12.2021

changed

Application-wide rewrite.

2.1

1.0

06.09.2007

created

First version.

1.0