PRB: #DEFINE in Setup Code Ignored If Only Line of Code

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

SYMPTOMS

If a single #DEFINE preprocessor directive is used in the Setup code of a screen, the constant is never defined and the following error message is generated when the constant is referenced:

   Variable ["<variable>"] not found.

RESOLUTION

To avoid this problem, add a comment somewhere in the Setup code. For an example, see "Workaround" in the "More Information" section below.

MORE INFORMATION

The #DEFINE preprocessor directive is used to create compile-time constants in programs. Using #DEFINE to create constants instead of using memory variables can save on memory consumption, increase performance, and simplify programs.

Steps to Reproduce Behavior

  1. Create new screen.

  2. In the Setup code, enter the following command:

          #DEFINE x 10
    

  3. To test the value of x, add a push button to the screen. In the VALID clause of the push button, enter this command:

          WAIT WINDOW STR(x)
    

  4. Save, generate, and run the screen.

  5. Click the push button. You will receive the following error message:

         Variable 'x' not found
    

Open the screen program (.SPR file). There will not be any generated Setup code, even though the #DEFINE was added above.

Workaround

  1. Open the screen (.SCX) file again.

  2. Open the Setup code and add a comment somewhere in the Setup code.

  3. Generate the screen again.

  4. Click the push button. A wait window should appear with "10" as its prompt.


Additional reference words: FoxDos FoxWin 2.50 2.50a 2.50 2.60
KBCategory: kbenv kbprg kbprb
KBSubcategory: FxenvMemory


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.