Returning from a function

Moderator: MacroQuest Developers

kellewic
a lesser mummy
a lesser mummy
Posts: 38
Joined: Tue Jun 08, 2004 2:27 am
Location: AZ

Returning from a function

Post by kellewic » Tue Jul 04, 2006 4:50 pm

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?