Microsoft KB Archive/140614

= PRB: SYS(2004) Returns Incorrect Directory =

Article ID: 140614

Article Last Modified on 2/10/2000

-

APPLIES TO


 * Microsoft Visual FoxPro 3.0 Standard Edition

-



This article was previously published under Q140614



SYMPTOMS
SYS(2004) returns incorrect information. According to the online Help file, SYS(2004) should return the name of the directory or folder from which Visual FoxPro was started. However, if you are running several instances of Visual FoxPro, the SYS(2004) function returns only the directory from which the first instance was started.



CAUSE
Executable files created in Visual FoxPro are not standalone applications. They rely on the Vfp300.esl as a runtime library. The SYS(2004) function returns the location of this file during run time. Even if you have multiple copies of this run-time library, the operating system will not load several instances into memory; it only opens one copy. That is why the SYS(2004) function only reports the location of the first one that was started.



RESOLUTION
You can use one of the following alternate methods to obtain the startup directory:


 * Use the CURDIR function to retrieve the working directory.
 * Store the name of the startup directory in a lookup table.
 * Write the location of the directory to an .ini file by using API calls.



STATUS
This behavior is by design.



MORE INFORMATION
For information about an alternative method of obtaining the path to the installation, please see the following article in the Microsoft Knowledge Base:

138937 How to Tell Which Directory Holds a Visual FoxPro App's .Exe

Steps to Reproduce Behavior
  Create a program file that contains the following line repeated twice: WAIT WINDOW SYS(2004)  Add this program to a new project, and build an executable. Create a second, new project and add the same program to it. Create this executable with a different name and save it into a different directory. Copy the Vfp300.esl file into both of the directories, or place the Windows\System directory in your PATH statement. Create icons for each of the executables, and set the working directories to the executable's location.</li> Try running each application separately. The WAIT WINDOW will report the correct directory for each program.</li> Close the executables if they are open.</li> Start one of the executables. While it is waiting for you to press a key, start the other executable. You will now see that the second instance reports the same starting directory as the first one.</li></ol>

Additional query words: VFoxWin

Keywords: KB140614

-

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

© Microsoft Corporation. All rights reserved.