Groups

By default, all OmniMark rules are active all the time. You can activate and deactivate rules selectively by bundling your rules into groups. You can then selectively activate and deactivate the groups:

  group mary
     find "lamb"
        ...
     find "school"
        ...
  
  group tom
     find "piper"
        ...
     find "pig"
        ...
  
  group #implied
  process
     using group mary
      submit "Mary had a little lamb"
     using group tom
      submit "Tom, Tom, the piper's son"

In this program, only rules in the group mary are used to process input Mary had a little lamb. Only rules in the group tom are used to process Tom, Tom, the piper's son.

The group mary is activated by the using group prefix on the submit statement. This makes the group mary active for processing the submitted material.

Why the group #implied before the process rule? The process rule is a rule like any other, so it is affected by groups like any other rule. group #implied stands for the default group. (In a program with no groups, all rules are in the default group.) Only the default group is active when a program starts. All other groups are inactive. So, you have to have at least one rule in the default group in order to activate any of the other groups.

Any rule that occurs before the first group statement in your program automatically belongs to the default group, but, if you use groups, it is usually a good idea to place your global rules explicitly into group #implied. If you included a file that contains group statements and you don't explicitly assign your global rules to group #implied, your global rules will fall into the last group declared in the include file rather then the default group. (For this reason, it is a good idea, in any include file that uses groups, to end the file with the declaration group #implied.)

You cannot disable the default group, so rules in the default group are always active. For this reason, you may want to keep the number of rules in the default group to a minimum (but remember, you must have at least one).

Activating multiple groups

You have more than one group active at a time by connecting the group names with &:

  using group mary & tom & dick & harry

You can also add a group to the current set of active groups using #group to represent all active groups:

  using group mary & tom & #group

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 the specified execution scope, whereas those named in a next group is remain active indefinitely or until the end of a wrapping using group.