4D v13.4Open resource file |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
4D v13.4
Open resource file
Open resource file
The Open resource file command opens the resource file whose name or pathname you pass in resFileName. If you pass a file name, the file should be located in the same folder as the structure file of the database. Pass a pathname to open a resource file located in another folder. If you pass an empty string in resFileName, the Open File dialog box is presented. You can then select the resource file to open. If you cancel the dialog, no resource file is open; Open resource file returns a null DocRef and sets the OK variable to 0. By default, the command opens the resource fork of the file passed as parameter. If it is empty, the command opens the data fork of the file and accesses any resources found there. For more information, refer to the Current date section. If the resource file is opened correctly, Open resource file returns its resource file reference number and sets the OK variable to 1. If the resource file does not exist, or if the file you try to open is not a resource file, an error is generated.
Remember to call CLOSE RESOURCE FILE for the resource file. Note, however, that when you quit the application (or open another database), 4D automatically closes all the resource files you opened using Open resource file. Unlike the Open document command, which opens a document with exclusive read-write access by default, Open resource file does not prevent you from opening a resource file already open from within the 4D session. For example, if you try to open the same document twice using Open document, an I/O error will be returned at second attempt. On the other hand, if you try to open a resource file already open from within the 4D session, Open resource file will return the resource file reference number to the file already open. Even if you open a resource file several times, you need to call CLOSE RESOURCE FILE once in order to close that file. Note that this is permitted if the resource file is open from within the 4D session; if you try open a resource file already opened by another application, you will get an I/O error. WARNING:
After you have opened a resource file, you can analyze the contents of the file using the commands RESOURCE TYPE LIST and RESOURCE LIST. The following example tries to open, on Windows, the resource file “MyPrefs.res” located in the database folder:
$vhResFile:=Open resource file("MyPrefs";"res ") On Macintosh, the example tries to open the file “MyPrefs”. The following example tries to open, on Windows. the resource file “MyPrefs.rsr” located in the database folder:
$vhResFile:=Open resource file("MyPrefs";"rsr") On Macintosh, the example tries to open the file “MyPrefs”. The following example displays the Open file dialog box showing all types of files:
$vhResFile:=Open resource file("") The following example displays the Open file dialog box showing files created by the Create resource file command, using the default file type:
$vhResFile:=Open resource file("";"res ") If the resource file is successfully opened, the OK variable is set to 1. If the resource file could not be opened or if the user clicked Cancel in the Open file dialog box, the OK variable is set to 0 (zero). If the resource file is successfully opened using the Open file dialog box, the Document variable is set to the pathname of the file. If the resource file could not be opened due to a resource or I/O problem, an error is generated. You can catch this error with an error-handling method installed using ON ERR CALL. |
PROPERTIES
Product: 4D
INDEX HISTORY
Modified: 4D 2004 SEE ALSO |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||