Try OpenEdge Now
skip to main content
Object-oriented Programming
Programming with Class-based Objects : Using built-in system and object reference elements : ABL session object reference attributes
 

ABL session object reference attributes

The FIRST-OBJECT and LAST-OBJECT attributes on the SESSION system handle provide access to the list of currently instantiated objects, commonly referred to as the SESSION object chain. FIRST-OBJECT and LAST-OBJECT both hold references to Progress.Lang.Object objects. Once you get the first object reference in the list using FIRST-OBJECT or the last object reference in the list using LAST-OBJECT, you can use the NEXT-SIBLING and PREV-SIBLING properties on Progress.Lang.Object to walk the list of currently instantiated objects.
Because these are object references to Progress.Lang.Object, if you need to use the object as its instantiated type (the type referenced by the NEW function), you need to CAST the object to the required type. For more information on casting, see Object reference assignment and casting.
For example, you can display the list of class type names for all classes currently instantiated in the ABL session with the following code:
DEFINE VARIABLE myObj AS CLASS Progress.Lang.Object NO-UNDO.

myObj = SESSION:FIRST-OBJECT.REPEAT:
  IF myObj EQ ? THEN LEAVE.

  MESSAGE myObj:GetClass( ):TypeName VIEW-AS ALERT-BOX.
  myObj = myObj:NEXT-SIBLING.
END.
Note that object references on the SESSION object chain (such as the FIRST-OBJECT attribute and the NEXT-SIBLING object property) are not included in the reference count for garbage collection. When the AVM determines that an object's reference count is zero, it is garbage collected, even though the SESSION object chain still references it. Once it is garbage collected, the object is also removed from the SESSION object chain.