Create resource file

4D - Documentation   Français   English   German   4th Dimension 2004, Command Theme List   4th Dimension 2004, Command Alphabetical List   4th Dimension 2004, Constant Theme List   Back   Previous   Next

version 2004 (Modified)


Create resource file (resFilename{; fileType{; *}}) DocRef

ParameterTypeDescription
resFilenameStringShort or long name of resource file, or
empty string for standard Save File dialog box
fileTypeStringMac OS file type (4-character string), or
Windows file extension (1- to 3-character string), or
Resource ("res " / .RES) document, if omitted
*If passed = Use data fork
Function resultDocRefResource file reference number

Description

The Create resource file command creates and opens a new resource file whose name or pathname is passed in resFileName.

If you pass a filename, the file will be located in the same folder as the structure file of the database. Pass a pathname to create a resource file located in another folder.

If the file already exists and is not currently open, Create resource file overrides it with a new empty resource file. If the file is currently open, an I/O error is returned.

If you pass an empty string in resFileName, the Save File dialog box is presented. You can then choose the location and the name of the resource file to be created. If you cancel the dialog, no resource file is created; Create resource file returns a null DocRef and sets the OK variable to 0.

If the resource file is correctly created and opened, Create resource file returns its resource file reference number and sets the OK variable to 1. If the resource file cannot be created, an error is generated.

On Macintosh, the default file type for a file created with Create resource file is "res ". On Windows, the default file extension is ".res". To create a file of another type:

On Macintosh, pass the file type in the optional parameter fileType.

On Windows, in fileType, pass a 1- to 3-character Windows file extension or a Macintosh file type mapped using the command MAP FILE TYPES.

By default, if the * parameter is omitted, the command creates and opens the file resource fork. When this parameter is passed, the command creates and opens the file data fork (readable on both Mac OS and Windows platforms). For more information, refer to the Resources topic.

Remember to call CLOSE RESOURCE FILE for the resource file. Note, however, when you quit the application (or open another database), 4D automatically closes all the resource files you opened using Create resource file or Open resource file.

Examples

1. The following example tries to create and open on Windows, the resource file "MyPrefs.res" located in the database folder:

   $vhResFile:=Create resource file("MyPrefs";*)
   

On Macintosh, the example tries to create and open the file "MyPrefs".

2. The following example tries to create and open, on Windows, the resource file "MyPrefs.rsr" located in the database folder:

   $vhResFile:=Create resource file("MyPrefs";"rsr")

On Macintosh, the example tries to create and open the file "MyPrefs".


3. The following example displays the Save File dialog box:

   $vhResFile:=Create resource file("")
   If (OK=1)
      ALERT("You just created ""+Document+"".")
      CLOSE RESOURCE FILE($vhResFile)
   End if

See Also

CLOSE RESOURCE FILE, ON ERR CALL, Open resource file, Resources.

System Variables and Sets

If the resource file is successfully created and opened, the OK variable is set to 1. If the resource file could not be created or if the user clicked Cancel in the Save File dialog box, the OK variable is set to 0 (zero).

If the resource file is successfully created and opened through the Save File dialog box, the Document variable is set to the pathname of the file.

Error Handling

If the resource file could not be created or 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.


4D - Documentation   Français   English   German   4th Dimension 2004, Command Theme List   4th Dimension 2004, Command Alphabetical List   4th Dimension 2004, Constant Theme List   Back   Previous   Next