Microsoft KB Archive/156672

= PRB: "Variable is not found" Using #INCLUDE Files =

Article ID: 156672

Article Last Modified on 12/3/2003

-

APPLIES TO


 * Microsoft Visual FoxPro 3.0 Standard Edition
 * Microsoft Visual FoxPro 3.0b Standard Edition
 * Microsoft Visual FoxPro 5.0 Standard Edition
 * Microsoft Visual FoxPro 6.0 Professional Edition

-



This article was previously published under Q156672



SYMPTOMS
If a predefined constant is referenced in a class or form, the following error message may be displayed:

Variable " " is not found..

   



CAUSE
The header file of predefined compile-time constants has not been properly included in the class or form.



Method 1
Include the header file in class or form using the following steps:


 * 1) Open the class or form.
 * 2) From the Class or Form menu, choose Include File.
 * 3) In the Include File dialog box, specify the header file in the Include File text box or choose the three-dot button to open the Include dialog box and choose the file.

Method 2
Insert the #INCLUDE in the application menu's general options, in the menu setup snippet.

Method 3
In every event or method on the class or form that references the predefined constant, reissue the #INCLUDE " ".



STATUS
This behavior is by design.



MORE INFORMATION
Predefined constants are defined by the #DEFINE directive. Generally, a series of #DEFINEs is included in a header file. In turn, this header file is referenced by a #INCLUDE in the class or form. This error usually occurs because the #INCLUDE is issued in the Load event of the class or form. By the time the event or method is called on the class or form that references the predefined constants, the constant is out of scope.

Steps to Reproduce Behavior
 Create a new form.  In the Load event of the form, enter the following code: #INCLUDE C:\VFP\SAMPLES\MAINSAMP\INCLUDE\TASTRADE.H                             Add a Command button to the form. In the Click event of the Command button, add the following MessageBox that references a constant in the Tastrade.H file: =MessageBox(inifile) </li> Run the form, and click the Command button.</li></ol>

<div class="references_section">