[Table of Contents] [docx version]

WordprocessingML Reference Material - Table of Contents

Syntax:

IF Expression-1 Operator Expression-2 field-argument-1 field-argument-2

Expression-1:

expression

Expression-2:

expression

field-argument-1:

expression

field-argument-2:

expression

Description: Compares the values designated by Expression-1 and Expression-2 using the operator designated by Operator.

Operator can be any one of the six relational and equality operators specified for operator (§2.16.3.3).

If Operator is = or <>, Expression-2 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. If an asterisk is used in Expression-2, the portion of Expression-1 that corresponds to the asterisk, plus any remaining characters in Expression-2, shall NOT exceed 128 characters.

Field Value: field-argument-1 if the comparison is true; otherwise, field-argument-2.

Switches: None.

[Example: The following example specifies that if the customer order is greater than or equal to 100 units, the result is "Thanks"; but if the customer order is fewer than 100 units, the result is "The minimum order is 100 units":

{IF order >= 100 "Thanks" "The minimum order is 100 units" }

For other examples, see §2.16.2, and the COMPARE field (§2.16.5.15) and the QUOTE field (§2.16.5.55). end example]