Setting margins
You can control what portion of the pattern is available to match to by setting left and right margins.
You might want to restrict pattern-action sets to ranges of input tokens. For example, if your input consists of records each consisted of four lines, two lines of address information and zero, one, or two lines of department or institution names, you might want to search for an address line with a number, street name, and street type, process only that line, and retype the tokens to NULL.
If you did the same for the city, state, and postal line, you can be guaranteed that anything remaining is department or institution names.
This type of restricted processing can be accomplished by setting left and right margins. The default settings are: left margin is the first token and right margin is the last token. These settings can be changed by using the SET_L_MARGIN and SET_R_MARGIN actions. Each action takes one of two keywords followed by a number or number within square brackets. You can use the following syntax:
SET_L_MARGIN LINE number | OPERAND number
SET_R_MARGIN LINE number | OPERAND number
An example of restricting the action sets is as follows:
*^ | D | ?
SET_L_MARGIN OPERAND [3]
SET_R_MARGIN OPERAND [3]
In this example, both the left and right margins are set to operand three. Since more than one token can comprise the token set corresponding to the unknown alphabetic type ?, the left margin is always set to the first token of the set and the right margin is always set to the last token of the set.
The same holds true for the type **. If operand three has specified another type that can only refer to a single token, such as ^, setting both left and right margins to operand three results in the next pattern-action sets only seeing that single token. As with any pattern-action set, if the associated pattern does not match to the input record, the actions are ignored and the margins are left unchanged.
After processing is complete within the set of tokens specified by the left and right margins, you need to reset the margins to their widest setting to reposition the other lines or tokens. Use the keywords BEGIN_TOKEN for the left margin and END_TOKEN for the right margin:
SET_L_MARGIN OPERAND [BEGIN_TOKEN]
SET_R_MARGIN OPERAND [END_TOKEN]
It is important to note that if, after setting margins, you retype all tokens within the margins to NULL, you have no access to any other tokens. To execute the actions that reset the margins, you must use a pattern that does not require any token to be found. The normal method is, at the beginning of a process, to create a condition that tests true at any point in the pattern-action sequence. Your first pattern-action set could be:
&
COPY "TRUE" true
At some point after all visible tokens have been retyped to NULL, you can execute the margin resetting actions by using the following pattern-action sequence:
[true = "TRUE"]
SET_L_MARGIN OPERAND [BEGIN_TOKEN]
SET_R_MARGIN OPERAND [END_TOKEN]