# OOP Syntax Elements

REF( ) Function |

REF( { ADD | DROP } obj_id )

The REF( ) function can be used to monitor and control multiple instances of a specified object via its internal Reference Count:

| REF(obj_id) | Returns the current reference count for the specified obj_id
| REF(ADD obj_id) | Increments the reference count for the specified obj_id
| REF(DROP obj_id) | Decrements the reference count for the specified obj_id

When accessing an object, use REF (ADD obj_id) to indicate that the application is to use the object (and to increment the reference count). When finished, use REF (DROP obj_id) to decrement the reference count. When no other references exist, the object is automatically deleted.

Only when an object reference count goes to 0 does the system actually delete the object and all its properties. ON_DELETE logic is only executed at the point when the object reference count goes to zero. See On Create/On Delete Logic.

The DROP OBJECT may be used as another method for deleting an object.

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

## See Also

REF( ) Function