taylansan Posted May 27, 2007 Share Posted May 27, 2007 ok here is a simple code and plz tell me how i can get 2 output function $x = 5 ;the problem is here i think? $a = myFunc($x) ;$a1 = ???? ;$a2 = ???? MsgBox(0,"",$a) Func myFunc($x) $y1=$x*$x $y2=$y1*$x ;is here correct? Return $y1 & $y2 EndFunc now i need $a1 = 25 and $a2 = 125. but miss or my lack of knowladge, i cant handle, i get $a = 25125. because i didnt ..emm seperate them? ... how can i get those values, withousing global or etc, i mean is there a way to write ($a1, $a2) = myFunc($x) [$a1, $a2] = myFunc($x) well tried but didnt work TY. Link to comment Share on other sites More sharing options...
Rick Posted May 27, 2007 Share Posted May 27, 2007 how this... $x = 5 $a = myFunc($x) MsgBox(0,"",$a[1] & @cr & $a[2]) Func myFunc($x) Dim $y[3] $y[1]=$x*$x $y[2]=$y[1]*$x Return $y EndFunc Who needs puzzles when we have AutoIt!! Link to comment Share on other sites More sharing options...
taylansan Posted May 27, 2007 Author Share Posted May 27, 2007 wow thank you Rick TY. Link to comment Share on other sites More sharing options...
smashly Posted May 27, 2007 Share Posted May 27, 2007 (edited) Don't know if it'll work or help, maybe you could try ..$x = 5 ;the problem is here i think? $a = myFunc($x) $spa = StringSplit($a, "|") MsgBox(0,"","$y1 = " & $spa[1] & @LF & "$y2 = " & $spa[2]) Func myFunc($x) $y1=$x*$x $y2=$y1*$x ;is here correct? Return $y1 & "|" & $y2 EndFunc Cheers Edit: I was to slow ..lol I like Rick's way better Edited May 27, 2007 by smashly Link to comment Share on other sites More sharing options...
Rick Posted May 27, 2007 Share Posted May 27, 2007 actually, it couldve been.. $x = 5 $a = myFunc($x) MsgBox(0,"",$a[0] & @cr & $a[1]) Func myFunc($x) Dim $y[2] $y[0]=$x*$x $y[1]=$y[0]*$x Return $y EndFunc Who needs puzzles when we have AutoIt!! Link to comment Share on other sites More sharing options...
flyingboz Posted May 27, 2007 Share Posted May 27, 2007 Rick's method shows you how to pass multiple paramaters via an array , each array element stores one value, and you track which one by the dimension in which the element is stored. This is useful, especially when you name your dimensions using Enum(). Of course, you could also just strip out the references to $y2, call the function twice, and store the result each time. To pass as a string, you could add a delimiter between your elements , and then parse the result. You can also use @error and/or @extended to pass numeric information. Reading the help file before you post... Not only will it make you look smarter, it will make you smarter. Link to comment Share on other sites More sharing options...
taylansan Posted May 27, 2007 Author Share Posted May 27, 2007 but what happens if i need those two variables, i mean not using array. y(1) and y(2) are array elements.. or a(1) and a(2) but i want a1 and a2, two variables here -.- confusing TY. Link to comment Share on other sites More sharing options...
Rick Posted May 27, 2007 Share Posted May 27, 2007 $x = 5 $a = myFunc($x) $a1=$a[0] $a2=$a[1] MsgBox(0,"",$a1 & @cr & $a2) Func myFunc($x) Dim $y[2] $y[0]=$x*$x $y[1]=$y[0]*$x Return $y EndFunc Who needs puzzles when we have AutoIt!! Link to comment Share on other sites More sharing options...
taylansan Posted May 27, 2007 Author Share Posted May 27, 2007 $a1=$a[0] $a2=$a[1] nice! TY. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now