SET RESOURCE PROPERTIES

4D - Documentation   Français   English   German   Spanish   4D v11 SQL, Command Theme List   4D v11 SQL, Command Alphabetical List   4D v11 SQL, Constant Theme List   Back   Previous   Next

version 6.0


SET RESOURCE PROPERTIES (resType; resID; resAttr{; resFile})

ParameterTypeDescription
resTypeString4-character resource type
resIDNumberResource ID number
resAttrNumberNew attributes for the resource
resFileDocRefResource 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:

ConstantTypeValue
System heap resource maskLong Integer64
System heap resource bitLong Integer6
Purgeable resource maskLong Integer32
Purgeable resource bitLong Integer5
Locked resource maskLong Integer16
Locked resource bitLong Integer4
Protected resource maskLong Integer8
Protected resource bitLong Integer3
Preloaded resource maskLong Integer4
Preloaded resource bitLong Integer2
Changed resource maskLong Integer2
Changed resource bitLong Integer1

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

SET RESOURCE NAME.

System Variables or Sets

The OK variable is set to 0 if the resource does not exist; otherwise, it is set to 1.


4D - Documentation   Français   English   German   Spanish   4D v11 SQL, Command Theme List   4D v11 SQL, Command Alphabetical List   4D v11 SQL, Constant Theme List   Back   Previous   Next