System Functions
REF( ) Control Reference Count
   
Formats REF({ADD|DROP|READ} obj_id)

Where:

ADD Keyword indicating an increment of the reference count for obj_id.
DROP Keyword indicating an decrement of the reference count for obj_id.
obj_id Object Identifier (number/handle) of the object being referenced
READ Keyword indicating no change to the reference count for obj_id.
   
Returns Current reference count value (0 if the object is deleted).
   
Description The REF ( ) function is used in Object Oriented Programming to control access to an object by incrementing or decrementing the reference count. The DROP OBJECT directive can also be used to destroy an object.

The system sets the reference count for any newly created object to 1 (one). If you plan to use an object more than once, use REF (ADD obj_id) to increment the reference count.

When finished with an object, use REF (DROP obj_id) to decrement the reference count. When the reference count becomes zero, the object is deleted.

Only objects whose reference count is 1 can be deleted. Once an object is destroyed, its identifier may be re-assigned to another object. You should no longer use the object identifier in your application, as it may reference a totally different object (if the identifier is re-assigned).

All objects are destroyed when the application issues a START directive or if the END directive is entered at command mode.

REF (READ obj_id) returns the current reference count value. All calls to REF( ) return the current reference count (or 0, if deleted).

   
See Also Object Oriented Programming
DEF CLASS Directive
PROPERTY Directive
LOAD CLASS Directive
DROP CLASS Directive
LOCAL Directive
FUNCTION Directive
LIKE Directive
PROGRAM Directive
RENAME CLASS Directive
STATIC Directive
DROP OBJECT Directive
NEW( ) Create new Object