DOCUMENT:Q121411  10-NOV-1994  [FOXPRO]
TITLE   :INF: How to Suppress Blank Fields in a Text Merge
PRODUCT :Microsoft FoxPro
PROD/VER:2.5x 2.60 2.60a | 2.00 2.5x 2.60 2.60a | 2.5x 2.60a
OPER/SYS:WINDOWS         | MS-DOS               | MACINTOSH
KEYWORDS:kbprg kbcode

--------------------------------------------------------------------
The information in this article applies to:

 - Microsoft FoxPro for Windows, versions 2.5x, 2.6, 2.6a
 - Microsoft FoxPro for MS-DOS, versions 2.0, 2.5x, 2.6, 2.6a
 - Microsoft FoxPro for Macintosh, versions 2.5x, 2.6a
-------------------------------------------------------------------

SUMMARY
=======

You can suppress blank fields in a FoxPro text merge by programmatically
creating the TEXTMERGE command and then using macro substitution to execute
the command, as shown in the example below.

MORE INFORMATION
================

This example assumes that you have a table with three fields

   NAME
   ADDRESS1
   ADDRESS2

and that you want to perform a text merge that produces output in the
following format:

   <Name>
   <Address1>
   <Address2>
   <Date>

   <Body of letter>

If the ADDRESS2 field is empty, you want the date to appear directly
underneath ADDRESS1, with no blank line where ADDRESS2 would normally
appear.

The following program illustrates how to create the desired output.

WARNING: ANY USE BY YOU OF THE CODE PROVIDED IN THIS ARTICLE IS AT YOUR OWN
RISK. Microsoft provides this code "as is" without warranty of any kind,
either express or implied, including but not limited to the implied
warranties of merchantability and/or fitness for a particular purpose.

   USE <table>
   SET TEXTMERGE TO outfile.txt
   SET TEXTMERGE ON
   SCAN
      * Test the ADDRESS2 field and return the appropriate text merge
      * character.
      cmnd=IIF(EMPTY(address2),"\\","\<<address2>>")
      \<<name>>
      \<<address1>>
      * Use macro substitution to execute the command.
      &cmnd
      \<<DATE()>>
      \
      \body of letter goes here
      * Print two empty lines between records.
      \
      \
   ENDSCAN
   SET TEXTMERGE OFF
   SET TEXTMERGE TO

REFERENCES
==========

FoxPro "Language Reference," SET TEXTMERGE command

Additional reference words: FoxMac FoxDos FoxWin 2.00 2.50 2.50a 2.50b
2.50c 2.60
2.60a
print
merge printmerge textmerge suppressing empty extra extraneous
KBCategory: kbprg kbcode
KBSubcategory:

=============================================================================

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.

Copyright Microsoft Corporation 1994.