How to Use the #INSERT Preprocessor Directive

ID: Q109145

The information in this article applies to:

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:

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

Last Reviewed: June 27, 1995