|
Wrapping records |
Pipelines v1.6 |
.* Example by TenFiftyTwo(c). |
.* The following pipeline handles two input arguments:.*.* &arg1. The name of a file to read..* &arg2. The maximum record length+1. .* The pipeline reads the input file: &arg1, and formats each paragraph so that, where possible,.* each record is no longer than &arg2-1 characters and displays the result on the console. If a.* record comprises a single word which is longer than &arg2-1 characters in length, the record.* remains unchanged. .* Note. leading and embedded whitespace is maintained. pipe (endchar ? comment //)
< &arg1 // Read input file. | strip trailing // Trim off trailing whitespace, so we can find blank records. | xlate x20 xfe // Change spaces to x'fe'. | a: locate // Route out blank records. | specs 1-* 1 xfe n // Append a x'fe' to the end of each record. | b: faninany // Merge in the modified blank records. | split after str xfe // Split into separate records. | join * &arg2 // Join records up to a maximum length of &arg2. | xlate xfe x20 // Change x'fe' to spaces. | change xff .. // Delete blank record fillers. | cons // Display on the console. ? a: | specs pad xff xff 1.&arg2 // Fill blank records with the filler char: x'ff'. | b: // Route back to main pipeline.