WD: SET Fields Within IF Field Evaluate Incorrectly

Last reviewed: February 2, 1998
Article ID: Q97791
The information in this article applies to:
  • Microsoft Word for Windows, versions 2.0, 2.0a, 2.0a-CD, 2.0b, 2.0c, 6.0, 6.0a, 6.0c
  • Microsoft Word for Windows 95, versions 7.0, 7.0a
  • Microsoft Word for the Macintosh, versions 6.0, 6.0.1, 6.0.1a
  • Microsoft Word 97 for Windows
  • Microsoft Word 98 Macintosh Edition

SYMPTOMS

When you use an IF field to determine how to set a bookmark, and you use SET fields inside the IF field, the bookmark being set always evaluates as the second SET statement.

For example, these statements

      {ask gender "What is the person's gender?"}
 -->  {if gender = f {set pronoun she}{set pronoun he}}
      {ref pronoun}

always show the bookmark "pronoun" as "he." This is because Word evaluates fields from the inside out, and from left to right. It evaluates the first SET statement, and the bookmark "pronoun" is set to "she." It then evaluates the next SET field, and the bookmark "pronoun" is reset to "he." When the IF instruction is carried out, both the true bookmark and the false bookmark are "he."

WORKAROUND

The correct way to use these fields together is to put the IF field inside the SET field, as in the following example:

      {ask gender "What is the person's gender?"}
 -->  {set pronoun {if gender = f "she" "he"}}
      {ref pronoun}


Additional query words: winword2 define assign wrong value incorrect
Keywords : kbfield winword word6 word7 word95 word97 macword98 kbualink97
Version : WINDOWS:2.x,6.0,6.0a,6.0c,7.0,7.0a,97; MACINTOSH:6.0,6.0.1,6.0.1a,98
Platform : MACINTOSH WINDOWS
Issue type : kbprb
Solution Type : kbworkaround


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: February 2, 1998
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.