![]() ![]() ![]() ![]() ![]() ![]() ![]() |
|||||
|
|
|||||
| Changing and adding to the currently active rule groups | |||||
| Prerequisite Concepts | |||||
Using the group declaration, you are able to bundle rules into groups which you can then switch on and off with the using group command. More than one group can be made active by joining the group names with the keyword and in the using group command.
There may be some situations in which you want to add a group to the currently active groups without explicitly naming each of these groups. This can be accomplished by using the #group keyword instead of naming all of the already active groups. For example, suppose the rule groups "foo" and "bar" are both active, and you want to add group "baz" to the list of currently active groups. The following process rule names all three groups in a using group command, making them all active:
process
using group foo and bar and baz
submit "foo.txt"
Alternately, however, you can use the #group keyword instead of naming groups "foo" and "bar":
process
using group #group and baz
submit "foo.txt"
Groups can also be changed by using a next group is command. The difference between using group and next group is is that the group or groups named in the using group are active for the duration of a single action, whereas those named in a next group is are active indefinitely.
The next group is command allows you to change which groups are active in the middle of a rule. For example, the following program will remove ignore-marked sections. Since ignore-marked sections can be nested to an arbitrary depth, you can't write a single pattern to match a whole marked section. This program uses next group is commands to switch between groups as required:
process
repeat over #command-line-names
using group document
submit file #command-line-names
again
global counter ignore-level
group document
find ul "<![ignore["
set ignore-level to 1
next group is ignore
group ignore
find [any except "]<"]+
; discard (optimization -- grabs as much as possible in one pattern)
find "]]>"
decrement ignore-level
next group is document when ignore-level = 0
find ul "<![ignore["
increment ignore-level
find any
; discard
It is important to understand that changing the active rule groups in one domain will not change the active groups in any other domain.
|
Prerequisite Concepts Groups |
| ---- |