PRB: #DEFINE with Equal Sign Causes a Syntax Error

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

SYMPTOMS

In a compiled program, a constant defined with the #DEFINE clause causes a "Syntax Error" message when the constant is used in subsequent code snippets.

CAUSE

The #DEFINE clause was incorrectly coded. An equal sign in the #DEFINE clause results in a "Syntax Error" message when the constant is used in subsequent code. For example, the following code will cause the error:

   #DEFINE salestax = .10
   sale = 123.45
   * The following line produces a syntax error.
   invtotal = sale * (1 + salestax)

RESOLUTION

Remove the equal sign (=) from the #DEFINE clause. Correct syntax for the #DEFINE clause is as follows:

   #DEFINE salestax .10

NOTE: #DEFINE is a preprocessor directive, not a screen generator directive. Therefore, it is not listed in the generator directive section of the "Developer's Guide" for version 2.5.

REFERENCES

"Language Reference," version 2.5, Chapter 3


Additional reference words: FoxDos FoxWin 2.50 define # 2.50a
KBCategory: kbprg kbprb
KBSubcategory: FxprgGeneral


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.