Just for the case, you are lost in the working memory space and desperately searching the spot(s) in your programm where a specific object is once again referenced, here a small handy method which could help you
/// find all variables which contain a given object(reference)
///
/// I: the OREF you looking for
///
/// O: "" if the spool-device can't be opened
/// [] if no variables contain the given OREF
/// [var1, var2, ... varN] an array of variable names (incl. subscripted and orefs)
///
ClassMethod FindObject(obj)
{
set res=[]
if $d(%)#10,%=obj do res.%Push("%")
new % set %=obj kill obj
lock +^SPOOL("nextID") // adapt this lines
open 2:($o(^SPOOL(""),-1)+1):1 // to your method of
lock -^SPOOL("nextID") // creating new spool IDs
if $t {
use 2
set spl=$zb
do $system.OBJ.ShowReferences(.%,1)
for i=1:1:$za-1 {
set x=$p($zstrip(^SPOOL(spl,i),"<=>w",$c(13,10))," ",3)
do:x]"%.~" res.%Push(x)
}
close 2
kill ^SPOOL(spl)
} else { set res="" }
quit res
}
Example
USER>kill
USER>set pers=##class(DC.Person).%OpenId(1)
USER>set temp=pers, zz(3)=temp
USER>write ##class(DC.Help).FindObject(pers).%ToJSON()
["pers","temp","zz(3)"]
- Log in to post comments