version 6.0
DELETE RESOURCE (resType; resID{; resFile})
Parameter | Type | Description | |
resType | String | 4-character resource type | |
resID | Number | Resource ID number | |
resFile | DocRef | Resource file reference number, or | |
current resource file, if omitted |
Description
The DELETE RESOURCE command deletes the resource whose type is passed in resType and whose ID number is passed in resID.
If you pass a valid resource file reference number in the parameter resFile, the resource is searched for within that file only. If you do not pass resFile, the resource is searched for within the current open resource files.
If the resource does not exist, DELETE RESOURCE does nothing and sets the OK variable to 0 (zero). If the resource is found and deleted, the OK variable is set to 1.
WARNING: DO NOT delete resources that belong to 4D or to any System files. If you do so, you may provoke undesired system errors.
Examples
1. The following example deletes the resource "STR#" ID=20000:
` Note that this example will delete the first "STR#" ID=20000 resource ` found in any resource file currently open: DELETE RESOURCE ("STR#";20000)
2. The following example deletes the resource "STR#" ID=20000 if it is found in a specified resource file:
` Note that this example will delete the resource "STR#" ID=20000 ` only if it is present in the resource file specified by $vhResFile: DELETE RESOURCE ("STR#";20000;$vhResFile) ` Note also that if there is such a resource in a currently open ` resource file other than that specified by $vhResFile, this resource ` is left untouched
3. The project method DELETE RESOURCES OF TYPE deletes all the resources of the type specified (as the second parameter) from the resource file specified (as the first parameter):
` DELETE RESOURCES OF TYPE Project Method ` DELETE RESOURCES OF TYPE ( Time ; String ) ` DELETE RESOURCES OF TYPE ( resFile ; resType ) C_TIME($1) C_STRING(4;$2) RESOURCE LIST($2;$aiResID;$asResName;$1) If(OK=1) For($vlElem;1;Size of array($aiResID)) DELETE RESOURCE($2;$aiResID{$vlElem};$1) End for End if
After this project method is present in a database, you can write:
` Delete all the resource of type "PREF" from the resource file $vhResFile DELETE RESOURCES OF TYPE ($vhResFile;"PREF")
4. The project method DELETE RESOURCE BY NAME deletes a resource (of a specific type) whose name is known:
` DELETE RESOURCE BY NAME Project Method ` DELETE RESOURCE BY NAME ( Time ; String ; String ) ` DELETE RESOURCE BY NAME ( resFile ; resType ; resName ) C_TIME($1) C_STRING(4;$2) C_STRING(255;$3) RESOURCE LIST($2;$aiResID;$asResName;$1) If(OK=1) $vlElem:=Find in array($asResName;$3) If($vlElem>0) DELETE RESOURCE($2;$aiResID{$vlElem};$1) End for End if
After this project method is present in a database, you can write:
` Delete, from the resource file $vhResFile, the resource "PREF" whose name is "Standard Settings": DELETE RESOURCE BY NAME ($vhResFile;"PREF";"Standard Settings")
See Also
RESOURCE LIST, SET RESOURCE PROPERTIES.
System Variables and Sets
The OK variable is set to 0 if the resource does not exist. If the resource has been deleted, the OK variable is set to 1.