DOCUMENTATION

This BAL called module copies a line of text, compressing each imbedded string of multiple blanks into a single blank.  The caller passes the addresses of the line and its length, and the program overwrites them with the compressed line and its shortened length.  This program is efficient only in processing lines that contain long strings of blanks or non-blanks.  Otherwise, a program that employs simple compare-and-copy logic without the TRT instruction would be far more efficient.

Three executed instructions are used to scan for the next blank and next non-blank, and to copy a string of non-blanks.  R5 masks TEXTAREA and marks the position in the line that will next be scanned.  R9 masks OUTAREA and marks the position in the line that will next be overlaid.  R4 holds the length of the portion of the line that remains to be scanned.

The Non-Blank Finder scans a 256-byte portion of the line for a non-blank, and if it fails to find one, it repeats the scan, beginning at the next 256-byte portion, until it finds a non-blank, or reaches the end of the line.  If it finds a non-blank, it stores the address in R1, inserts a blank in the current output position, and reduces R4.

The String-Copy Routine scans a 256-byte portion of the line for a blank, and if it fails to find one, it repeats the scan, beginning at the next 256-byte portion, until it finds a blank, or reaches the end of the line.  For each scanned 256-byte length, it copies the traversed string of non-blanks to the current output position, and reduces R4.  If it finds a blank, it stores the address in R1.

The COBOL caller invokes this routine to compress a line in Working Storage by:

01  TEXT-1         PIC  X(50).
01  LEN            PIC S9(4) COMP.

MOVE LENGTH OF TEXT-1  TO LEN.
CALL 'CMPRSTXT'  USING LEN
                       TEXT-1.


Copyright © 2009 The Stevens Computing Services Company, Inc.  All rights reserved.