The uselogic attribute
The uselogic attribute of the <description> element allows you to define more complex logical relations among multiple descriptors than are available with the default combining method described in the previous section.
If you use the uselogic attribute, then the macro runtime ignores the Inverse Descriptor settings and the Optional settings in the individual descriptors.
You have to add the uselogic attribute to the <description> element manually using the the Code Editor. The Macro Editor does not provide a control for this.
The value of the uselogic attribute is a
simplified logical expression whose terms are 1-based indexes of the
descriptors that follow. Figure 1 shows an
example of a <description> element that contains a uselogic attribute
(some of the attributes of the <string> element are omitted for
clarity):
Figure 1. Example
of the uselogic attribute of the <description> element
In the figure above the value of the uselogic attribute
is:
<description uselogic="(1 and 2) or (!1 and 3)" />
<oia status="NOTINHIBITED" optional="false" invertmatch="false"/>
<string value="'Foreground' row="5" col="8"/>
<cursor row="18" col="19" optional="false" invertmatch="false"/>
</description>
(1 and 2) or (!1 and 3)
This logical expression is not
a regular logical expression (as described in Conditional and logical operators and expressions) but rather a simplified style
of logical expression used only in the uselogic attribute.
The rules for this style of logical expression are:
- The numerals 1, 2, 3, and so on stand for the boolean results of, respectively, the first, second, and third descriptors in the <description> element (<oia>, <string>, and <cursor> in the figure above). You can use any numeral for which a corresponding descriptor exists. For example, if a <description> element has seven descriptors, then you can use 7 to refer to the boolean result of the seventh descriptor, 6 to refer to the boolean result of the sixth descriptor, and so on.
- Only the following logical operators are allowed:
Table 1. Logical operators for the uselogic attribute Operator: Meaning: and Logical AND or Logical OR (inclusive) ! Logical NOT (inversion) - You can use parentheses () to group terms.
- The following entities are not allowed:
- Arithmetic operators and expressions
- Conditional operators and expressions
- Variables
- Calls to Java methods
In the example in Figure 1 the macro runtime
will determine that the description as a whole is true if:
- The result of the first descriptor is true and the result of the second descriptor is true (1 and 2); or
- The result of the first descriptor is false and the result of the third descriptor is true (!1 and 3).
Remember that if you use the uselogic attribute, then the macro runtime ignores the Inverse Descriptor settings and the Optional settings in the individual descriptors.