BUG: #UNDEFINE Not Releasing Constant in a Screen

Last reviewed: April 30, 1996
Article ID: Q119762
The information in this article applies to:
  • Microsoft FoxPro for Windows, version 2.6
  • Microsoft FoxPro for MS-DOS, version 2.6
  • Microsoft FoxPro for Macintosh, versions 2.5b, 2.5c

SYMPTOMS

A constant is not released from memory even though the #UNDEFINE <constant name> preprocessor directive is written into a screen snippet. The screen code generator program, GENSCRN.PRG, ignores this line. Consequently, the generated file (.SPR) is missing the #UNDEFINE line of code.

CAUSE

The preprocessor directive #UNDEFINE <constant name> releases the constant created by the preprocessor directive #DEFINE <constant name> from memory at run time. The screen generator program, GENSCRN.PRG, is missing a condition for a code snippet line beginning with the #UNDEFINE command, in the procedure WRITECODE.

RESOLUTION

To correct this problem, modify the generated screen code file (the .SPR file) and add in the #UNDEFINE <constant name> directive where needed, or modify the GENSCRN.PRG file as outlined below.

A minor modification to the GENSCRN.PRG program will enable this command. Add the following line of code to the CASE statement "CASE m.upline = #" at around line 2942, in the procedure WRITECODE:

   OR LEFT(m.upline,5) = "#UNDE" ;

After modification, the code in the CASE statement should be similar to the code below:

   CASE m.upline = "#"
        * don't output a generator directive, but #DEFINES are OK
        IF LEFT(m.upline,5) = "#DEFI" ;
          OR LEFT(m.upline,5) = "#UNDE" ;
          OR LEFT(m.upline,3) = "#IF" ;
          OR LEFT(m.upline,5) = "#ELSE" ;
          OR LEFT(m.upline,6) = "#ENDIF" ;
          OR LEFT(m.upline,8) = "#INCLUDE"
     \<<m.line>>
     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

Steps to Reproduce Problem

Place the following code in the setup code snippet of a screen. Generate the screen, then run the generated code program.

   #DEFINE x 2
   ? x
   #UNDEFINE x
   ? x

The number 2 will be output twice to the FoxPro desktop; however, you should receive the error message "Variable 'X' not found" when the second "? x" command is encountered at run time. This error never appears because the line

   #UNDEFINE x

is not generated into the .SPR file.


Additional reference words: FoxMac FoxDos FoxWin 2.50b 2.50c 2.60
buglist2.50b
buglist2.50c
buglist2.60 #UNDE UNDEFINE
KBCategory: kbprg kbbuglist
KBSubcategory: FxtoolSbuilder


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: April 30, 1996
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.