Page 1 of 1

Returning from a function

Posted: Tue Jul 04, 2006 4:50 pm
by kellewic
I just cannot figure this out. I can return simple variables no problem from functions. Returning things like objects, arrays, collections, etc still eludes me

I've tried:

Code: Select all

function:array xxx()
{
    variable string ret[2]

    ret[1]:Set[a]
    ret[2]:Set[b]

    return ${ret}
}
I've also tried replacing 'function:array' with 'function:variable' and I keep getting the error "Could not initialize array object for function return value". It seems it's not trying to return a reference to the variable, but that it's trying to create a new array to return which is not what I want.

How do I return a reference to the array?

I'm sure I could work around this by declaring a global array to hold the values and not return it, but just reference the global variable. I just wonder why I can't return a reference?