Jump to content

alternative to return multiple variables?


Recommended Posts

Cheers,
I have a plan to develop something but there is a problem. I want to develop a load function, this function will generate two arrays with totally different values and the problem is how AutoIT could return these two different arrays in one function. Here's an example of what I'm trying to say:

local $aArray1, $aArray2
$aArray1, $aArray2 = _Test_func()
Func _Test_func()
local $aArrayA = [1, 2, 3]
local $aArrayB = [4, 5, 6]
return $aArrayA, $aArrayB
EndFunc

 

Edited by Mateocedillo
Link to comment
Share on other sites

I think that global array or ByRef parameters would be the best (and the most simple) solution.

 

But here is another quite simple example/solution using (1D) array of (two) arrays:

#include <Array.au3>
#include <Debug.au3>

local $aArray0, $aArray1, $aArray2

$aArray0 = _Test_func()
$aArray1 = $aArray0[0]
$aArray2 = $aArray0[1]
_DebugArrayDisplay($aArray1)
_DebugArrayDisplay($aArray2)

Func _Test_func()
    Local $aArrayRet[2]
    local $aArrayA = [1, 2, 3]
    local $aArrayB = [4, 5, 6]
    $aArrayRet[0] = $aArrayA
    $aArrayRet[1] = $aArrayB
    return $aArrayRet
EndFunc

 

Edited by Zedna
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...