Question
· Jul 27, 2021

How do I pass an array by reference and get back all modifications to the array (including subscript additions)

I have a routine tag that takes an argument and I want this argument to be an array reference.  So I try something like:

do mytag(.myarr)

The mytag tag, adds subscripts to myarr.

When I evaluate myarr after the tag call, only the subscripts passed in are retained in myarr.  The subscripts added by mytag are missing.  Is there a way to pass an array so it will behave the way I want it to?

Product version: Caché 2017.1
$ZV: Cache for Windows (x86-64) 2017.1.3 (Build 317_5_19833) Wed Apr 1 2020 11:36:20 EDT
Discussion (6)0
Log in or sign up to continue

I would have responded with a similar option:

classmethod ABC(byref p1 as %String(MAXLEN=*)) as %Status

set tSC=$$$OK

try {

     if $g(p1("{some_attribute_name}")) set .....

    set p1("{a_new_node"})="{a_value}")

    }

...

But if you wanted to keep it in proper objects pass in p1, byref, as a %ListOfDataTypes or %ListOfObjects or %ArrayOfDataTypes or %ArrayOfObjects depending on whether you are passing in an ordered list or and subscripted array