Written by

Senior Cloud Architect at InterSystems
Question Eduard Lebedyuk · Jan 14, 2020

Getting dynamic object from iterator

Is there a way to get dynamic object from iterator?

set arr=[1,2,3]
set iter=arr.%GetIterator()

I pass iterator several frames down and I'd rather avoid passing both the array and iterator, but for debugging I need to access original object in a situation where only iterator is available.

Is there a way to do it?

Comments

Rubens Silva · Jan 14, 2020

Looks like there's a pvaoref property that points to the original instance as you can see below:

Method %OnNew(oref As %Library.DynamicAbstractObject) As %Status [ Private, ProcedureBlock = 1, ServerOnly = 1 ]
{
	set i%pointer = -1
	set ..pvaoref = oref
	return $$$OK
}

And it seems to work:

USER>set a = []
 
USER>set it = a.%GetIterator()
 
USER>w it.pvaoref
1@%Library.DynamicArray
USER>
0
Eduard Lebedyuk  Jan 14, 2020 to Rubens Silva

I get this error on access:

<PRIVATE PROPERTY>

And the property is indeed marked as private.

0
Rubens Silva  Jan 14, 2020 to Eduard Lebedyuk

sighs

I should have expected that much. Which version are you using?

0