How to Merge Text from a Memo Field

ID: Q97644

2.50 2.50a 3.00 | 2.00 2.50 2.50a

WINDOWS         | MS-DOS
kbprg

The information in this article applies to:

SUMMARY

Memo fields provide a powerful way to implement text merges in FoxPro. The information below provides the code to print the contents of memo fields containing the text for a text merge.

MORE INFORMATION

In this example, the memo field contains the text to be merged with the text merge components. The page spacing (top, bottom, and side margins) is controlled within the memo field. A sample memo field will appear much like this:

   <<DATE()>>

   <<ALLTRIM(PROPER(CONTACT))>>
   <<ALLTRIM(PROPER(COMPANY))>>
   <<ALLTRIM(PROPER(ADDRESS))>>
   <<ALLTRIM(PROPER(CITY))>>, <<ALLTRIM(STATE)>> <<ALLTRIM(ZIP)>>

   Dear <<ALLTRIM(PROPER(CONTACT))>>:

   This area includes the body of a letter to be sent to the contact.

   Sincerely,

   Author's name

The following code prints the letter from the memo field shown above. The text merge components (the fields and such) are in the SAMPLE\DBFS subdirectory of FoxPro for MS-DOS and the SAMPLE\ORGANIZE\DBFS subdirectory of FoxPro for Windows.

  CLEAR
  SET PRINTER ON
  SET TEXTMERGE ON                && enable evaluation of components
  SET TALK OFF                    && prevents printing of commands
  SET TEXTMERGE DELIMITERS TO     && set default delimiters
  SET MEMOWIDTH TO 80             && sets memo width for 80 columns
  USE Clients
  SCAN                            && forces top-down processing
   FOR J=1 TO MEMLINES(<memo>)    && processes each line in memo field
      X="\"+MLINE(<name of memo field>,J)
      &X                          && macro substitution
   ENDFOR
  ENDSCAN

NOTE: If the print job doesn't print until you quit FoxPro, see the following article in the Microsoft Knowledge Base:

   ARTICLE-ID: Q102203
   TITLE     : PRB: Print Job Is Not Released to Printer

For more information about performing text merges, see the following article in the Microsoft Knowledge Base:

   ARTICLE-ID: Q97163
   TITLE     : General Text Merge Functionality

Additional reference words: VFoxWin 3.00 FoxDos FoxWin 2.00 2.50 2.50a KBCategory: kbprg kbvfp300 kbvfp500 kbvfp600 KBSubcategory: FxprgMacrosub
Keywords          : FxprgMacrosub 
Version           : 2.50 2.50a 3.00 | 2.00 2.50 2.50
Platform          : MS-DOS WINDOWS

Last Reviewed: October 23, 1998