Removing multiple blocks of records

Pipelines v1.6

 

.* Example by TenFiftyTwo(c).

Home

 
.* The following pipeline reads the file: Startup.ini and removes all of the [TCPIP] sections.
.* This pipeline construction can be used to remove any number of blocks of records that begin and
.* end with a known label, ie) character or characters. In this example, each block of records that
.* start with the expression '\[tcpip([0-9])*\]' and end with the record immediately before a record
.* which starts with the character '[', are removed.
 
pipe (endchar ? escape %)
     < &installdrive:\&installpath\Examples\Input\Startup.ini .* Read the input file.
     | change 1 /[/ /@[/                              .* Insert an '@' infront of any '[' character.
     | split after str /@/                            .* Split a record after an '@' character.
     | a: between casei() reg /\[tcpip([0-9])*\]/ /@/ .* Discard records..
     | hole                                           .* ..up to the next marker.
     ?
     a:
     | nlocate 1 /@/                                  .* Discard any marked records.
     | cons                                           .* Display the selected records on the console.