When the Picture or Regular Expression find string of your CHANGE command locates data of varying lengths, if may be more convenient to refer to data positions relative to the end of the string, rather than relative to the beginning. Suppose we find a string containing abcPDQxyz. (Remember that the string that is found is the source string.)
The regular enumeration of the source string value is as follows:
End-relative enumeration of this same source string value is the reverse of that:
Now, if every string you found were exactly 9 positions long, and you wanted the last 3 positions, you could easily get them with a column range of 7-9. But, if the strings varied in size from 5 to 20 characters, what could you use to get those last 3 positions? Without using end-relative notation, there is no easy way to do it.
To specify an end-relative column reference, you use a single column number, or a column range with two number separated by a – minus sign, and then follow it with an * asterisk.
Examples, using the source string noted above:
Note carefully: When an end-relative column range is used, a notation of first‑second* selects columns in reverse order when first is smaller than second (like 1‑3*), and in forward order when first is larger than second (like 3-1*). Because of this, you must use this notation carefully and not get these confused.
The column ordering is the exact opposite of how normal column-range references are done, where a range like 1-3 is forward order, and 3-1 is reverse order. This is necessary in order to be consistent with how the columns are numbered in reverse order (as shown above), when end-relative column numbering is used.
Example: To select the last 3 positions of a variable length field and convert them to upper case, use this:
Example: To select the last 3 positions of a variable length field and convert them to upper case, and reverse their order, use this:
End-relative notation can be used to on any command that accepts a column reference.
End-relative notation cannot be combined with + remaining-column notation, and 0 cannot be used as a column number. (Those capabilities are not really needed with end-relative notation, since you can already reverse the columns selected by switching the two numbers in a range.)
The range of column numbers that can be used for end-relative notation is the same as for regular notation:
The Mapping Strings Quick Reference has several examples of how all the various column reference types are specified and what they mean.
Created with the Personal Edition of HelpNDoc: Full-featured EPub generator