Microsoft KB Archive/156342

= PRB: DO  Runs Cached Version of Program =

Article ID: 156342

Article Last Modified on 12/1/2003

-

APPLIES TO


 * Microsoft Visual FoxPro 3.0 Standard Edition
 * Microsoft Visual FoxPro 3.0b Standard Edition
 * Microsoft Visual FoxPro 5.0 Standard Edition
 * Microsoft Visual FoxPro 6.0 Professional Edition

-



This article was previously published under Q156342



SYMPTOMS
If you run a program file, change the default directory, and then attempt to run a different program of the same name from that directory, the first program runs again.



CAUSE
For performance purposes, program or procedure code is cached in memory. The version in memory is used when the same procedure or program name is executed again.



WORKAROUND
Use the CLEAR PROGRAM command before running the second program of the same name.

-or-

Reference the program explicitly by path, for example: DO .\



STATUS
This behavior is by design.



Steps to Reproduce Behavior
Run the following code from a program (.prg) file: * Start of code example *  LOCAL lcCurDir, lnI lcCurDir=SET('default')+CURDIR  && Save the current directory CLEAR MD c:\testxx           && Make the new directory FOR lnI = 1 TO 2 MD 'c:\testxx\t'+ALLTRIM(STR(lnI))  && Make one of the subdirs CD 'c:\testxx\t'+ALLTRIM(STR(lnI))  && Change to it      * Put the program code into the clipboard _CLIPTEXT = '? " This is in My_Prog from T'+ALLTRIM(STR(lnI))+'"' KEYBOARD '{ctrl + v}'     && This will paste it into the program KEYBOARD '{ctrl + w}'     && This will close the editor MODIFY COMMAND My_Prog && Open the editor - then the above 2 &&    keystrokes will be processed DO My_Prog            && Run the program ENDFOR FOR lnI = 1 TO 2 CD 'c:\testxx\t'+ALLTRIM(STR(lnI))  && Change to one of the subirs DELETE FILE My_Prog.FXP             && Delete the .PRG/.FXP file DELETE FILE My_Prog.PRG CD .. RD 'c:\testxx\t'+ALLTRIM(STR(lnI))  && Remove the subdir ENDFOR

CD (lcCurDir)           && Switch to the original default RD c:\testxx            && Remove the directory *  * End of code example Both messages printed to the FoxPro desktop refer to the T1 directory.

Demonstration of Workaround 1:

  Add a CLEAR PROGRAM command immediately before the DO My_Prog command in the above example: CLEAR PROGRAM DO My_Prog  Rerun the program, and note that the first message printed to the FoxPro desktop refers to the T1 directory, and the second refers to T2.

Demonstration of Workaround 2:

  Remove the CLEAR PROGRAM command if added above, and change the DO My_Prog command in the above example to read as follows: DO .\My_Prog  Rerun the program, and note that the first message printed to the FoxPro desktop refers to the T1 directory, and the second again refers to T2.</li></ol>

You can hard code the path name, but the .\ works for any current directory.

Additional query words: kbdse VFoxWin

Keywords: KB156342

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.