Sign in to follow this  
Followers 0
Ropetin Again

'Return' Multiple Values

4 posts in this topic

I'm sure this is REALLY obvious, but my brain is fried after staring at the screen for ~8 hour so far today. I couldn't find anything in the Help File, and my forum search didn't seem to hit anything appropriate.

I have a user-defined function that processes some information passed to it. Currently it returns one value, but I would like it to return two values. Is this possible, and if so, does anyone have some basic example code?

Thanks!

Share this post


Link to post
Share on other sites



Return an Array with the multiple values.

I'm sure this is REALLY obvious, but my brain is fried after staring at the screen for ~8 hour so far today. I couldn't find anything in the Help File, and my forum search didn't seem to hit anything appropriate.

I have a user-defined function that processes some information passed to it. Currently it returns one value, but I would like it to return two values. Is this possible, and if so, does anyone have some basic example code?

Thanks!

Share this post


Link to post
Share on other sites

Either return an array or pass values by reference.

$out1 = ""
$out2 = ""

MyFunc(4)

MsgBox(0,"","$out1: " & $out1 & @CRLF & "$out2: " & $out2)

Func MyFunc($in, ByRef $out1, ByRef $out2)
$out1 = $in *2
$out2 = $in / 2
EndFunc

$result = MyFunc(4)

MsgBox(0,"","$result[0]: " & $result[0] & @CRLF & "$result[1]: " & $result[1])

Func MyFunc($in, ByRef $out1, ByRef $out2)
Local $array[2]

$array[0] = $in *2
 $array[0] = $in / 2

Return $array
EndFunc

Share this post


Link to post
Share on other sites

Both of you; THANK YOU THANK YOU THANK YOU!

Share this post


Link to post
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
Sign in to follow this  
Followers 0