17.16.5.10 COMPARE
Description: Compares the values designated by the two expressions in comparison using the operator designated by comparison-operator. [Note: This field can be used to create compound logical comparisons with AND and OR functions in a formula, and then by using the result of the formula in an IF field. end note]
[Note: comparison-operator can be any one of the six relational and equality operators specified for operator (17.16.3.3). end note]
If comparison-operator is = or <>, the left-hand expression operand can contain a question mark (?) to represent any single character, or an asterisk (*) to represent any string of characters. The expression shall be enclosed in quotation marks so that it is compared as a character string.
Field Value: 1 if the comparison is true, or 0 if the comparison is false.
Switches: None.
[Example: Consider the case in which the IF field in the following example is inserted into a mail merge main document. The COMPARE fields examine the data fields CustomerNumber and CustomerRating as each data record is merged. The OR function of the formula returns the value 1 if at least one of the data fields indicates poor credit, in which case the first text in quotation marks is printed:
{ IF { = OR ( { COMPARE { MERGEFIELD CustomerNumber } >= 4 }, { COMPARE { MERGEFIELD CustomerRating } <= 9 } ) } = 1 “Credit not acceptable” “Credit acceptable”}
The following COMPARE field results in the value 1 if any value in the PostalCode data field is the range 98500– 98599:
{ COMPARE “{ MERGEFIELD PostalCode }” = “985*” }
end example]
Syntax: