Microsoft KB Archive/42368

= OPEN with No Path Defaults to Current Folder; CHDIR Changes =

Article ID: 42368

Article Last Modified on 11/21/2006



This article was previously published under Q42368



SUMMARY
When you OPEN a data file for INPUT, random, or APPEND access in Macintosh QuickBASIC and specify no folder or disk path, QuickBASIC looks for the file in the &quot;current folder.&quot;

In interpreted programs, the &quot;current folder&quot; defaults to the folder where QuickBASIC itself is running. In compiled programs, the &quot;current folder&quot; defaults to the folder where the compiled application is running.

You can use the CHDIR statement to change the current folder to any path, such as to the location of the data file that is being opened.



MORE INFORMATION
The following CHDIR statement makes all subsequent OPEN &quot;filename&quot; statements look in the folder called &quot;folder1&quot; on the disk volume called &quot;Volume&quot;:   CHDIR &quot;Volume:Folder1:&quot; OPEN &quot;filename&quot;          ' Looks for &quot;Volume:Folder1:filename&quot; Note: You can also specify full pathnames for data files (such as OPEN &quot;Volume:folder1:filename&quot;). A disadvantage of this is that your program will not be able to find the file if it is moved somewhere else.

You may find it more flexible to use OPEN statements WITHOUT an explicit path, such as OPEN &quot;filename&quot;. Statements of this form use the current search path, and can automatically remember a new path through the &quot;Can't Find: &quot; dialog when run on write-enabled disks.

The &quot;Can't Find File&quot; dialog box displays if a data file OPENed for INPUT, APPEND, or random access is not in the current folder. This dialog lets you locate the data file in a different folder. If you successfully locate the file through this dialog, the program (compiled or interpreted) permanently remembers the default folder in the new location. (The &quot;Disable File Not Found&quot; option in Run Options... must be OFF for this to work.)

You can disable the &quot;Can't Find: &quot; processing by selecting the &quot;Disable File Not Found Dialog&quot; option in Options... from the QuickBASIC Run menu. If this option is selected, a run-time error 53: &quot;File Not Found&quot; occurs on the OPEN when a file cannot be found in the current folder or with the specified full path.

Additional query words: MQuickB

Keywords: KB42368

-

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

© Microsoft Corporation. All rights reserved.