Jump to content

Recommended Posts

Posted (edited)

ok this isn't udf it just shows how you can return an array, and a string at the same time, unfortunetly uncommented it justs returns an array of an array, and a string..

$a = _ArrStr()

MsgBox(0,'String',$a[1])

$a = $a[0]

For $x =1 to UBound($a)-1
    MsgBox(0,'Array',$a[$x])
Next

Func _ArrStr()
    Local $retArray[2]
    Local $aArray[11]
    Local $sString
    
    For $x = 1 to 10
        $aArray[$x] = $x
        $sString &= $x 
    Next
    
    $retArray[0] = $aArray
    $retArray[1] = $sString
    
    Return $retArray
EndFunc
Edited by mrRevoked
Don't bother, It's inside your monitor!------GUISetOnEvent should behave more like HotKeySet()
Posted (edited)

I guess that would work, but isn't that what ByRef is for?

well yes, and no.. no.. when you set byref, the input has to be a variable and it overwrites the variable with new data if you use it..

you could use it like this.. but it's more of an array swap than anything..

local $a[5] = [0,1,2,3,4]

func _text(byref $a)
$string = '12345'

local $b[5] = [6,7,8,9,0]
$a = $b
return string
endfunc

just use your imagination..

Edited by mrRevoked
Don't bother, It's inside your monitor!------GUISetOnEvent should behave more like HotKeySet()
Posted (edited)

Here is your code from the first post rewritten with a ByRef

#include <array.au3>
Dim $a[1]
$s = _ArrStr($a)

MsgBox( 0, "String", $s )
_ArrayDisplay($a, "Array" )

Func _ArrStr(ByRef $aArray)
    ReDim $aArray[11]
    Local $sString
    
    For $x = 1 to 10
        $aArray[$x] = $x
        $sString &= $x 
    Next
    
    Return $sString
EndFunc

Either way works and both return the same string and array.

Edited by Gabburd

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
  • Recently Browsing   0 members

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