Fields

The \field control word introduces a field destination, which contains the text of fields. Fields have the following syntax:

<field> '{' \field <fieldmod>? <fieldinst> <fieldrslt> '}'
<fieldmod> \flddirty? & \fldedit? & \fldlock? & \fldpriv?
<fieldinst> '{\*' \fldinst <para>+ <fldalt>? '}'
<fldalt> \fldalt
<fieldrslt> '{' \fldrslt <para>+ '}'

There are several control words that alter the interpretation of the field. These control words are listed in the following table.

Control word Meaning
\flddirty A formatting change has been made to the field result since the field was last updated.
\fldedit Text has been added to, or removed from, the field result since the field was last updated.
\fldlock Field is locked and cannot be updated.
\fldpriv Result is not in a form suitable for display (for example, binary data used by fields whose result is a picture).

Two subdestinations are required within the \field destination. They must be enclosed in braces ({ }) and begin with the following control words.

Control word Meaning
\fldinst Field instructions. This is a destination control word.
\fldrslt Most recent calculated result of the field. This is a destination control word.

If the instruction for a field contains a file name, then the \cpg control can be used to define the character set of the file name. See “Code Page Support” on page 9 of this Application Note for details.

The \fldrslt control word should be included even if no result has been calculated because most readers (even those readers that do not recognize fields) can generally include the value of the \fldrslt destination in the document. A field result should not start with a table, because this will break some RTF readers.

An example of some field text follows:

{\field {\*\fldinst AUTHOR \\*MERGEFORMAT    }{\fldrslt Joe Smith}}\par\pard
{\field{\*\fldinst time \\@ "h:mm AM/PM"}{\fldrslt 8:12 AM}}

You can use the \fldalt control word to specify that the given field reference is to an endnote. For example, the following field in RTF is a reference to a footnote

{\field{\*\fldinst NOTEREF _RefNumber } {\fldrslt 1}}

The following is an example of a reference to an endnote

{\field{\*\fldinst NOTEREF _RefNumber \fldalt } {\fldrslt I}}

If the specified field is a form field, the \*\datafield destination appears as a part of <char> and contains the binary data of a form field instruction. For example:

{\field{\*\fldinst {\*\bkmkstart Text1} FORMTEXT {{\*\datafield 
00000000000000000554657874310008476565207768697a0000000000000000000000}}}{\fldrslt Default Result}}{\*\bkmkend Text1}

Note that the \datafield destination requires the \* prefix. The \fldtype, \date, \time, and \wpeqn field keywords should be ignored.