BUG: #UNDEFINE Not Releasing Constant in a Screen

ID: Q119762

2.60    | 2.60   | 2.50b 2.50c
WINDOWS | MS-DOS | MACINTOSH kbprg kbbuglist

The information in this article applies to:

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

Keywords          : FxtoolSbuilder kbbuglist
Version           : 2.60    | 2.60   | 2.50b 2.50c
Platform          : MACINTOSH MS-DOS WINDOWS

Last Reviewed: May 2, 1996