BUG: #IF <System Memvar> Returns "Invalid Preprocessor..."

Last reviewed: February 16, 1996
Article ID: Q115953
The information in this article applies to:
  • Microsoft FoxPro for Windows, versions 2.5, 2.5a, 2.5b, 2.6
  • Microsoft FoxPro for MS-DOS, versions 2.5, 2.5a, 2.5b, 2.6
  • Microsoft FoxPro for Macintosh, versions 2.5b, 2.5c

SYMPTOMS

The compiler directives #IF ... #ENDIF used with the _DOS, _WINDOWS, _MAC, and _UNIX system memory variables generate an "Invalid preprocessor expression" error message when compiled under FoxPro for Windows and FoxPro for Macintosh. FoxPro for MS-DOS does not produce any error messages when the same code is compiled. Instead, it compiles the statement following #IF _DOS and displays "This displays only when running under DOS".

RESOLUTION

To obtain the desired results when using preprocessor directives, run the following code in all three products:

   #IF 'WINDOWS' $ UPPER(VERSION())
            ? "This should display only when running under Windows"
   #ELIF 'MAC' $ UPPER(VERSION())
        ? "This should display only when running on the Macintosh"
   #ELSE
        ? "This should display only when running under DOS"
   #ENDIF

STATUS

Microsoft has confirmed this to be a problem in the Microsoft products listed at the beginning of this article. We are researching this problem and will post new information here in the Microsoft Knowledge Base as it becomes available.

MORE INFORMATION

Both FoxPro for Windows and Macintosh return the expected results because the _DOS, _WINDOWS, _MAC, and _UNIX system memory variables are not considered preprocessor definitions since they are evaluated at run time, not compile time.

The online help system for FoxPro for Windows, MS-DOS, and Macintosh contains the following warning:

NOTE: Do not use system memory variables for <expN1> or <expL1>. System memory variables are not evaluated until run time.

Steps to Reproduce Problem

  1. Load FoxPro for Windows and run the following program:

          #IF _WINDOWS
    
                 ? "This displays only when running under Windows"
          #ENDIF
    
          #IF _MAC
                ? "This displays only when running on the Macintosh"
          #ENDIF
    
          #IF _DOS
               ? "This displays only when running under DOS"
          #ENDIF
    
    

  2. Issue the MODIFY FILE <filename.ERR> command. Note that there are three compile errors (for example, "Invalid preprocessor expression") listed in the .ERR file. Close FoxPro for Windows.

  3. Load FoxPro for MS-DOS and run the same program. Make sure that the .FXP file does exist before you issue the DO <filename.prg> command. This will ensure that FoxPro for MS-DOS will recompile the program.

FoxPro for MS-DOS will display the following message:

   This displays only when running under DOS


Additional reference words: FoxMac FoxDos FoxWin 2.50 2.50a 2.50b 2.60
2.50c
buglist2.50
buglist2.50a buglist2.50b buglist2.60 buglist2.50c memvar
KBCategory: kbenv kbprg kberrmsg kbbuglist
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: February 16, 1996
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.