Microsoft KB Archive/35659

From BetaArchive Wiki
Knowledge Base


QuickBASIC "Device I/O Error" Using CloseResFile on Source

Article ID: 35659

Article Last Modified on 11/21/2006

This article was previously published under Q35659

SUMMARY

There is a correction for the "Note" in Section E.6.2, "Resource Files," on Page 435 of the manual "Microsoft QuickBASIC for Apple Macintosh: BASIC Language Reference." The "Note" should be changed to read as follows:

"It is dangerous to close the resource fork of a currently running program."

This means that you should NEVER perform CloseResFile on the file reference number of a currently running program; otherwise, you can get "Device I/O Error" in the QuickBASIC environment and/or eventually lose your interpreted source file. If you need to write resource changes to the resource fork of a currently running (or loaded) program, perform UpdateResFile instead of CloseResFile.

MORE INFORMATION

Note that you can open external resource files with the OpenResFile statement, and close them with the CloseResFile statement. However, you should never need to perform OpenResFile on the currently running program, since it is already open, and the SYSTEM(7) function returns its file reference number.

The SYSTEM(7) function returns the file reference number of the resource fork of the program source file when the program is interpreted. SYSTEM(7) returns the file reference number of the application resource fork in a compiled application. A common programming practice is to store user-defined resources in their own resource fork instead of in a separate resource file.

You are allowed to perform CloseResFile on any resource file other than a currently running program. However, UpdateResFile must be used instead of CloseResFile to write resources to currently running (or loaded) program files.

You should NEVER perform a CloseResFile statement using the number returned by SYSTEM(7). In interpreted programs, you can cause a "Device I/O Error" at save time if you previously did a CloseResFile on the resource fork of the source file or of QuickBASIC itself. This can put garbage in the "QuickBasic Settings" file in your System Folder. To clean up the QuickBASIC settings, drag the "QuickBasic Settings" file into the trash on the desktop.

It is also possible to hang QuickBASIC with a program that closes QuickBASIC's or its own resource fork. If in doubt, use UpdateResFile instead of CloseResFile to write resource changes to disk.


Additional query words: MQuickB

Keywords: KB35659