Syntax


COMPRESS

 string-1  [ string-2 ] 

[ start-column [ end-column ] ] 

[ line-control-range ]

[ color-selection-criteria]

[ color-change-request]

[ X | NX ]

[ U | NU }

[ MX | DX ]  

[ ALL ]

[ TOP ]


Operands


string-1

The string being searched for. The string should contain the single occurrence of the value you wish to compress, unless you also specify string-2. See Description for issues related to Text, Picture and Regular-Expression search strings.


string-2


The string that replaces string-1. String-2 must be shorter than string-1.

start-column

Left column of a range (with end-column) within which the from-string value must be found. If no end-column operand, then the from-string operand must be found starting in start-col.


end-column

Right column of a range (with end-column) within which the from-string value must be found. 


line-control-range

The range of lines which are to be processed by the command. Line control ranges provide a powerful tool to customize the range of lines to be processed. The full syntax and allowable operands which make up a line control range are discussed in "Line Control Range Specification". Refer to that section of the documentation for details.  


color-selection-criteria

A request for selection based on the highlight color of the from-string. Color requests provide another powerful tool to control search selection. The full syntax and allowable operands which make up a color-selection-criteria  are discussed in "Color Selection Criteria Specification". Refer to that section of the documentation for details.


color-change-request

A request for selection based on the highlight color of the from-string. Color requests provide another powerful tool to control search selection. The full syntax and allowable operands which make up a color-selection-criteria  are discussed in "Color Selection Criteria Specification". Refer to that section of the documentation for details.


X | NX

Specifies a subset of the line range to be processed. X requests only excluded lines are to be processed, NX requests only non-excluded lines are to be processed. If neither X or NX are specified, all lines in the range will be processed.


U | NU

Specifies a subset of the line range to be processed. U requests only User lines are to be examined, NU requests only non-User lines are to be examined. If neither U or NU are specified, all lines in the range will be examined.


MX

MX requests that all lines which DO contain from-string be excluded from the display following command processing. MX = Make Excluded.


DX

DX requests that lines which DO contain from-string, which, if excluded, would normally be made visible, be left in their excluded status. DX = Don't change Excluded status.


ALL

ALL requests that all lines in the line range will be compressed. If the ALL option is omitted, then by default the first line in the lines in the line range will be compressed. Note that this default action is what is done in other SPFLite commands when a NEXT operand is used. However, be aware that COMPRESS does not support any of the options FIRST, LAST, PREV or NEXT.


TOP

Normally, at the completion of the command, the first, or only, line processed is highlighted (if it is on the current screen) or the screen is scrolled to the 2nd screen line (as ISPF does) if the line is not on the current screen. If TOP is coded, then the line is always positioned as the top line of the screen, regardless of its current location.


 

Abbreviations and Aliases


COMPRESS can also be spelled as CP

 

 Description


COMPRESS is used for two purposes: (1) you can specify a single string, to collapse repetitive spans of a search string to single occurrences of that string, and (2) you can specify two strings to repetitively change a longer string to a shorter one. The first action is called string compressing, and the second is called string condensing.


String Compressing


Every span of strings is compressed on each line of the selected line range if you say ALL; otherwise, just the first available line in the line range is compressed. For example, to compress spans of multiple * characters on the first two lines of a file, you could issue a command like this:


Command > COMPRESS '*' ALL U


U2 001 *** ABC *** DEF ***

000002 *** PDQ *** XYZ ***

000003 *** 123 *** 456 ***


Result:


000001|* ABC * DEF *

000002|* PDQ * XYZ *

000003 *** 123 *** 456 ***


String Condensing


Condensing text means to repetitively change one string into a shorter string. There are no restrictions on the values you choose to condense text, except that the replacement text in string-2 must be shorter than string-1. String-2 can be a zero-length string, so that all occurrences of string-1 are removed.


SPFLite condenses a line by scanning it for any occurrence of string-1, and when found, replaces it with string-2. If any replacements were made, the line is scanned again to see if any additional occurrences of string-1 are found, and these are again replaced with string-2. This continues until no more replacements can be made.


This is best explained by an example. Suppose you had a line with words having a closing parenthesis with space between them, and you wanted to remove the extra space, and further assume that the spacing before the parentheses are unequal. Let's say the line looked this this:

 

000001 (ABC   )     (DEF       )

 

Now, you could issue many CHANGE commands like CHANGE ' )' ')' ALL to remove all the extra blanks, which would require a lot of typing. Or, you could do a simple COMPRESS ' ' but that would compress ALL blanks, not just the blanks before the parentheses, and also would not remove all blanks between the word and the right parentheses. Instead, let's use COMPRESS with the second string operand. What we need is  COMPRESS ' )' ')'. This causes ALL instances of ' )' to be replaced with  ')'. Result:

 

000001 (ABC)     (DEF)


Considerations when using non-specific search strings in COMPRESS


The COMPRESS search string can be any SPFLite string type, including T, P and R, and untyped strings when CASE T is in effect. When strings of such types are used, it is possible that more than one kind of character will match the search string. For example, T'a' will match on 'a' or 'A', and P'#' will match digits '0' through '9'. Because these types of strings do not match one value alone they are called non-specific strings.  When COMPRESS is provided with a non-specific string to search for, it finds the first actual string that matches the non-specific search item, and that actual value is used to compress any further repetitions of itself.


For example, given a line that contained 111222333, a command of COMPRESS P'#' ALL will produce 123. Even though all nine digits in 111222333 match against  P'#' in a FIND or CHANGE command, only identical spans of digits get compressed. 


The reason that 111222333  does not compress down to a single digit is that COMPRESS first matches the non-specific string P'#' to the actual string '1' and from that point on, only '1' characters are matched and compressed. The first instance of '2' starts a new string, and then the non-specific string P'#' matches the actual string '2' and from that point on, only '2' characters are matched and compressed, and so on. This same principle applies to Text strings, Pictures and Regular Expression strings.


This rule may seem a little complicated, but it's only reasonable to do it this way. After all, if COMPRESS really did reduce a string like 111222333 to a single digit, which one would it pick?  1, 2 or 3?  Or something else?  The way it does it as described above is the only way that makes sense. If you really wanted to collapse strings like 111222333 to a single digit, the best way to do it would be to first issue a command like CHANGE  P'#' '9' ALL on the lines where you wanted to do this, then go back and  COMPRESS '9' as needed.

Created with the Personal Edition of HelpNDoc: Maximize Your Documentation Capabilities with HelpNDoc's User-Friendly UI