To Uppercase

Pipelines v1.6

 

.* Example by TenFiftyTwo(c).

Home

 
.* The following pipeline changes the first letter of each word in the file: example.txt to uppercase
.* and displays the records on the console.
 
.* The pipeline preserves leading, trailing and embedded whitespace, blank records (comprising spaces
.* and tabs) and null records. The pipeline manipulates the records by inserting a number of placement
.* characters: x'fd', x'fe' and x'ff' into the records to serve as markers that aid in splitting and
.* joining the records. The pipeline assumes that these placement characters are not already present
.* in the input file.
 
pipe (endchar ? comment //)
     < &installdrive:\&installpath\Examples\Input\example.txt // Read the input file.
     | a: locate              // Send null records to second pipeline.
     | b: faninany            // Read from both streams.
     | specs 1-* 1 xfe n      // Append a x'fe' to each record.
     | xlate x20 xff          // Change a space to x'ff'.
     | split after str xff    // Separate a record into words/records at each x'ff' character.
     | xlate 1 upper          // Translate the first byte of each word/record to uppercase.
     | join until str xfe     // Concatenate records until the first byte of a record is x'fe'.
     | split at str xfe       // Split each record into multiple records at a x'fe' character.
     | change 1 xfd ''        // Remove the leading x'fd' character.
     | xlate xff x20          // Change x'ff' characters back to spaces.
     | cons                   // Display on the console.
     ?
     a:
     | specs xfd 1            // Replace a null record with a record containing a x'fd' character.
     | b: