Microsoft KB Archive/168058

= PRB: Application Wizard EXE or APP Gives Path or File Error =

Article ID: 168058

Article Last Modified on 8/20/1999

-

APPLIES TO


 * Microsoft Visual FoxPro 5.0 Standard Edition
 * Microsoft Visual FoxPro 5.0a

-



This article was previously published under Q168058



SYMPTOMS
If an EXE or APP built from a project created by the Application Wizard is run from a directory on a drive that does not contain the home directory of the application project and source files, one or more of the following errors will occur:

"Invalid path or file name"

-or-

"File " \ .mpr" not found"



CAUSE
The application home directory is hard-coded into the project's main program, and the wzApplication.DoMenu method contains a check for the existence of the .MPR file, while the EXE or APP only contains the compiled MPX code.



Invalid Path or File name
  To alleviate the "Invalid path or file name" error, open the main program in the project created by the Application Wizard. The main program will have the same name as the project name and is located in the " \Progs" directory. It will also appear in bold in the Project Manager's Code tab under the Programs heading. Replace the line: CD "" 

with the following: * Are we running from a PRG (FXP)? If so, strip off all after the * last 2 "\" characters else strip all after the last "\" character

CD (SUBSTR(SYS(16,0),1,RAT('\',SYS(16,0), ;       IIF(".FXP"$SYS(16,0),2,1))-1))

  In the WZApplication.DoMenu method located in the class library \VFP\wizards\appwiz.vcx, the following code is used to verify the existence and then call menus used within the application: LPARAMETERS tcFileName LOCAL lcFileName

lcFileName=ALLTRIM(tcFileName) IF EMPTY(lcFileName) RETURN .F.     ENDIF lcFileName=LOWER(FULLPATH(lcFileName)) IF NOT "."$lcFileName lcFileName=lcFileName+".mpr" ENDIF IF NOT FILE(lcFileName) this.FileNotFoundMsgBox(lcFileName) RETURN .F.     ENDIF DO (lcFileName) 

File Not Found
To alleviate the "File not found" error, change the line: lcFileName=lcFileName+".mpr" to: * Since the lowest level program is an FXP, we are not in an APP or EXE, * so it is OK to look for MPR since we know source code is available. * Otherwise look for MPX contained in APP or EXE

lcFileName = lcFileName+ iif(".FXP"$sys(16,0),".mpr", ".mpx")



STATUS
Microsoft is researching this problem and will post new information here in the Microsoft Knowledge Base as it becomes available.



Steps to Reproduce Behavior
  Type the following commands in the Command Window within Visual FoxPro: MD c:\awtest CD c:\awtest </li> Run the Application Wizard by selecting Tools/Wizards from the Visual FoxPro system menu. Select All from the submenu, then Application Wizard from the list and select OK.</li> In step 1, Call the application "awtest" and select Complete Application.</li> Select Finish.</li> Build this project into an EXE file.</li> Copy the EXE to a different directory than the one it was built in.</li> Run the EXE.</li></ol>

The steps in the RESOLUTION section above describe how to fix the main program in an application that has already been created. By the object- oriented nature of Visual FoxPro, the change in the DoMenu method will automatically be applied to future applications created with the Application Wizard. In order to fix the main program template so that future applications built with the Application Wizard will correctly resolve the default path, you must modify the template located in the Appwiz.dbf table. This can be done by completing the following steps:

  From the Command Window: USE HOME+'wizards\appwiz.dbf' BROWSE FOR type = 'STARTUP PROGRAM' MODIFY MEMO DATA1 </li>  Locate the following line in the memo edit window: *<CD>* </li>  Delete the above line, and replace it with: CD (SUBSTR(SYS(16,0),1,RAT('\',SYS(16,0), ;       IIF(".FXP"$SYS(16,0),2,1))-1)) </li> Close the edit window, then type USE in the Command Window to close the Appwiz table and save the changes.</li> Future applications created with the Application Wizard will contain both the changes in the main program and the DoMenu method, and neither of the errors described in the SYMPTOMS section above will occur.</li></ol>

Keywords: KB168058

-

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

© Microsoft Corporation. All rights reserved.