How to Use the #INSERT Preprocessor Directive

Last reviewed: June 27, 1995
Article ID: Q109145
The information in this article applies to:
  • Microsoft FoxPro for MS-DOS, versions 2.0, 2.5, 2.5a, 2.5b
  • Microsoft FoxPro for Windows, versions 2.5, 2.5a, 2.5b
  • Microsoft FoxPro for Macintosh, versions 2.5b

SUMMARY

You can include code written into a file in a screen or menu by using the #INSERT generator directive, as described below.

MORE INFORMATION

Although the "Developer's Guide" lists most of the generator directives supported by GENSCRN and GENMENU (the screen and menu generator programs), only the online help system describes the #INSERT generator directive. The online help gives the following syntax:

   #INSERT <file>

Developers familiar with C may be tempted to interpret the angle brackets as literals and incorporate them into the actual #INSERT statement. As described in the syntax conventions on page L1-8 of the FoxPro "Language Reference," angle brackets surrounding lowercase text indicate information that the user supplies.

To correctly use the #INSERT generator directive, do the following:

  1. Create a directory named C:\INCLUDES.

  2. Open a program file named INCLUDE.PRG, and enter the following code:

          WAIT WINDOW 'This is a test'
    

  3. Open a new screen. In the Setup code snippet for the screen, enter the following code:

          #INSERT c:\includes\include.prg
    

  4. Create a simple terminating push button, and then save, generate, and run the screen. Look at the screen program file (.SPR). The setup portion of the .SPR file details the source of the inserted text.

If the inserted source code is changed in the original file, the screen must be regenerated.

NOTE: Neither GENSCRN nor GENMENU allows quotation marks to be used to delimit the filename. This may cause problems on the Macintosh, which allows for volumes and filenames with embedded spaces. To work around this limitation, use the following guidelines when storing files to be inserted in a folder other than the default:

  • Use filenames without embedded spaces.
  • Use the SET VOLUME command during development to map drives and folders to an individual letter.


Additional reference words: MBuilder FoxMac FoxDos FoxWin 2.00 2.50 2.50a
2.50b
KBCategory: kbprg
KBSubcategory: FxtoolMBuilder


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: June 27, 1995
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.