version 6.0
SET RESOURCE PROPERTIES (resType; resID; resAttr{; resFile})
Parameter | Type | Description | |
resType | String | 4-character resource type | |
resID | Number | Resource ID number | |
resAttr | Number | New attributes for the resource | |
resFile | DocRef | Resource file reference number, or | |
current resource file, if omitted |
Description
The SET RESOURCE PROPERTIES command changes the attributes of 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 the parameter resFile, the resource is searched for within the current open resource files.
If the resource does not exist, SET RESOURCE PROPERTIES does nothing and sets the OK variable to 0 (zero).
The numeric value you pass in resAttr must be seen as a bit field value whose bits have special meaning. The following predefined constants are provided by 4D:
Constant | Type | Value |
System heap resource mask | Long Integer | 64 |
System heap resource bit | Long Integer | 6 |
Purgeable resource mask | Long Integer | 32 |
Purgeable resource bit | Long Integer | 5 |
Locked resource mask | Long Integer | 16 |
Locked resource bit | Long Integer | 4 |
Protected resource mask | Long Integer | 8 |
Protected resource bit | Long Integer | 3 |
Preloaded resource mask | Long Integer | 4 |
Preloaded resource bit | Long Integer | 2 |
Changed resource mask | Long Integer | 2 |
Changed resource bit | Long Integer | 1 |
Using these constants, you can build any resource attributes value. See examples below.
Resource Attributes and Their Effects
System heap
If this attribute is set, the resource will be loaded into the system memory rather than into 4D memory. You should not use this attribute, unless you really know what you are doing.
Purgeable
If this attribute is set, after the resource has been loaded, you can purge it from memory if space is required for allocation of other data. Since you load resources into 4D BLOBs, it is a good idea to have all your own resources purgeable in order to reduce memory usage. However, if you frequently access this resource during a working session, you might want to make it non-purgeable in order to reduce disk access due to frequent reloading of a purged resource.
Locked
If this attribute is set, you will not be able to relocate the resource (unmovable) after it is loaded into memory. A locked resource cannot be purged even if it is purgeable. Locking a resource has the undesirable effect of fragmenting the memory space. DO NOT use this attribute, unless you really know what you are doing.
Protected
If this attribute is set, you can no longer change the name, ID number or the contents of a the resource. You can no longer delete this resource. However, you can call SET RESOURCE PROPERTIES to clear this attribute; then you can again modify or delete the resource. Most of the time, you will not use this attribute. Note: This attribute has no effect on Windows.
Preloaded
If this attribute is set, the resource is automatically loaded into memory if the resource file where it is located is open. This attribute is useful for optimizing resource loading when a resource file is opened. Most of the time, you will not use this attribute.
Changed
If this attribute is set, the resource is marked as "must be saved on disk" when the resource file where it is located is closed. Since the 4D command SET RESOURCE handles the writing and rewriting of resources internally, you should not use this attribute, unless you really know what you are doing.
You will usually use the attribute purgeable and, more rarely, Preloaded and Protected.
WARNING: DO NOT change the attributes of resources that belong to 4D or to any System files. If you do so, you may provoke undesired system errors.
Examples
1. See example for the command Get resource name.
2. The following example makes the resource 'STR#' ID=17000 purgeable, but leaves the other attributes unchanged:
$vlResAttr:=Get resource properties ('STR#';17000;$vhResFile) SET RESOURCE PROPERTIES('STR#';17000;$vlResAttr ?+ Purgeable resource bit;$vhMyResFile)
3. The following example makes the resource 'STR#' ID=17000 preloaded and non purgeable:
SET RESOURCE PROPERTIES('STR#';17000;Preloaded resource mask;$vhResFile)
4. The following example makes the resource 'STR#' ID=17000 preloaded but purgeable:
SET RESOURCE PROPERTIES('STR#';17000;Preloaded resource mask+Purgeable resource mask;$vhResFile)
See Also
System Variables or Sets
The OK variable is set to 0 if the resource does not exist; otherwise, it is set to 1.