Microsoft KB Archive/42462

= &quot;Invalid Function Call&quot;; OpenResFile Makes Empty File; Path =

Article ID: 42462

Article Last Modified on 1/9/2003

-

APPLIES TO


 * Microsoft QuickBasic Compiler for Macintosh 1.0

-



This article was previously published under Q42462



SUMMARY
When using the OpenResFile statement, you must specify the complete path to the resource file being opened, such as in the following example: ref%=0 OpenResFile &quot;Examples:QB Demos:Demo Resources&quot;,ref% Otherwise, you must put the resource file in the current folder (the folder where QuickBASIC itself or the compiled application is located) and specify no path, as follows: ref%=0 OpenResFile &quot;Demo Resources&quot;,ref% If the file does not exist in the specified location, then OpenResFile will create an empty file with the specified name. If the file is created empty, it will have no resources, and calling a subsequent library routine that tries to pull a resource out of it may produce a run-time error, such as the following:

&quot;Invalid Function Call&quot;

NOTE: You can use CHDIR to change the current default folder where OpenResFile searches for unqualified filenames, as follows: CHDIR &quot;Examples:QB Demos:&quot; OpenResFile &quot;Demo Resources&quot;



MORE INFORMATION
This subject can be demonstrated by compiling the demonstration program DIALOG EXAMPLE, included with QuickBASIC Version 1.00 in the QB Demos folder. If the file is compiled into an application and put in a different folder, the program will not find the needed resources as it does inside the interpreter. (The interpreted version always finds the resources, which Microsoft stored in the resource fork of the source file itself.)

Here are three methods to make the compiled version of DIALOG EXAMPLE find the DEMO RESOURCES file:  Copy the DEMO RESOURCES file into the same folder as the DIALOG EXAMPLE APL compiled application.  Modify the source code of DIALOG EXAMPLE, changing the following line IF SYSTEM(4) THEN  'If compiled... OpenResFile &quot;Demo Resources&quot;,ref% to include the drive and path of the DEMO RESOURCES file, for example: IF SYSTEM(4) THEN  'If compiled... OpenResFile &quot;HD 20:Folder 1:Demo Resources&quot;,ref% Note that the SYSTEM(4) function returns a value of &quot;true&quot; (non-zero) when the program is compiled, and &quot;false&quot; (zero) when interpreted.   Modify the source code of DIALOG EXAMPLE and add a CHDIR statement to change the default directory. In the following example, CHDIR changes the default folder to &quot;Folder 1&quot; on the disk named &quot;HD 20&quot;: IF SYSTEM(4) THEN  'If compiled... CHDIR &quot;HD 20:Folder 1:&quot; OpenResFile &quot;Demo Resources&quot;,ref% 

Additional query words: MQuickB

Keywords: KB42462

-

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

© Microsoft Corporation. All rights reserved.