Caché ObjectScript Reference
$ISOBJECT
[Back] [Next]
   
Server:docs1
Instance:LATEST
User:UnknownUser
 
-
Go to:
Search:    

Returns whether an expression is an object reference.
Synopsis
$ISOBJECT(expr)
Parameter
expr A Caché ObjectScript expression.
Description
$ISOBJECT returns 1 if expr is an object reference. $ISOBJECT returns 0 if expr is not an object reference.
$ISOBJECT returns –1 if expr is a reference to an invalid object. Invalid objects should not occur in normal operations; an invalid object could be caused, for example, by recompiling the class while instances of the class are active.
To remove an object reference, set the variable to the null string (""). The obsolete %Close() method cannot be used to remove an object reference. %Close() performs no operation and always returns successful completion. Do not use %Close() when writing new code.
Parameter
expr
Any Caché ObjectScript expression.
Examples
The following example shows the values returned by $ISOBJECT for an object reference and a non-object reference (in this case, a string reference):
  SET a="certainly not an object"
  SET o=##class(%SQL.Statement).%New()
  WRITE !,"non-object a: ",$ISOBJECT(a)
  WRITE !,"object ref o: ",$ISOBJECT(o)
 
The following example shows how to remove an object reference. The %Close() method does not change the object reference. Setting an object reference to the null string deletes the object reference:
  SET o=##class(%SQL.Statement).%New()
  WRITE !,"objref o: ",$ISOBJECT(o)
  DO o.%Close()  ; this is a no-op
  WRITE !,"objref o: ",$ISOBJECT(o)
  SET o=""
  WRITE !,"objref o: ",$ISOBJECT(o)
 
See Also