I have a list of arrays. I need to perform a lookup to find the right array and then update a single key in the array. I'm wondering what the most efficient approach is. My initial attempt was to find the array I am targeting in a repeat loop, assign the found array to an <out> parameter, and the update the parameter.
Code: Select all
private handler _GetObjectArray(in pId as String, out rArray as Array) returns Boolean
variable tObject as Array
repeat for each element tObject in sObjects
if tObject["uuid"] is pId then
put tObject into rArray
return true
end if
end repeat
return false
end handler
private handler _SetObjectProperty(in pId as String, in pProperty as String, in pValue as any) returns nothing
variable tObject as Array
if (_GetObjectArray(pId, tObject) is false) then
_ThrowInvalidId(pId)
end if
put pValue into tObject[pProperty]
end handler
That doesn't work, however, as the array value stored in the list is never updated. I guess I was hoping that an <out> parameter was passed by reference. Is there a way to pass a pointer to a variable so that it can be updated? Or do I have to update the entire array in the list element every time I want to update a single key?