Arranging text in columns (vertical)

Pipelines v1.8

 

.* Example by TenFiftyTwo(c).

Home

 
.* The following pipeline reads the file: example.txt; splits each record into individual words 
.* and selects the first 150. Using this list of 150 words, it builds an output which consists of
.* three equal columns of 50 words, 30 characters wide.
 
.* This example is intended to demonstrate how SPECS can combine multiple input streams/records
.* into individual output records.
 
pipe (priority 2 endchar ?)
     < &installdrive:\&installpath\Examples\Input\example.txt .* Read input file.
     | split                         .* Split each record into individual words.
     | strip                         .* Trim whitespace.
     | locate                        .* Discard blank records.
     | take 150                      .* Select only the first 150 words.
     | specs recno 1 1-* nw          .* Insert record number in column 1.
     | a: drop 50                    .* Route away the first 50 records.
     | b: drop 50                    .* Route away the next 50 records.
     | c: specs select 1 1-* 1       .* Read a record from each of the three input streams..
                select 2 1-* 30      .* ..and build a single output record..
                select 0 1-* 60      .* ..comprising three columns.
     | cons                          .* Display on the console.
     ?
     a:
     | elastic                       .* Buffer as necessary, the first 50 records.
     | c:                            .* Route back to main pipeline.
     ?
     b:
     | elastic                       .* Buffer as necessary, the next 50 records.
     | c:                            .* Route back to main pipeline.