oldgeezer Posted January 10, 2006 Share Posted January 10, 2006 Is it possible to return more than one parameter with a function call like with other languages? For example, In the main body: ($output1, $output2) = Func_name($input1, $input2) I have tried this syntax and it doesn't work. Is there proper syntax for this? Link to comment Share on other sites More sharing options...
seandisanti Posted January 10, 2006 Share Posted January 10, 2006 Is it possible to return more than one parameter with a function call like with other languages? For example, In the main body: ($output1, $output2) = Func_name($input1, $input2) I have tried this syntax and it doesn't work. Is there proper syntax for this?i can't think of a language that lets you make 1 assignment to 2 variables in the same expression the way you have it there. the way to do what you want is to use arrays. have your function return an array dim blah blah = Test(1,2) Func Test($x,$y) dim $ToReturn[2] $ToReturn[0] = $x $ToReturn[1] = $y return($ToReturn) EndFunc Link to comment Share on other sites More sharing options...
The Kandie Man Posted January 10, 2006 Share Posted January 10, 2006 Yes, the easiest way to do this would be to return the values as an array. #include <Array.au3> $array = Func_name($input,input2) _ArrayDisplay ( $array, "This is the array" ) Func_Name($x,$y) Return StringSplit($x & "," & $y,",") EndFunc "So man has sown the wind and reaped the world. Perhaps in the next few hours there will no remembrance of the past and no hope for the future that might have been." & _"All the works of man will be consumed in the great fire after which he was created." & _"And if there is a future for man, insensitive as he is, proud and defiant in his pursuit of power, let him resolve to live it lovingly, for he knows well how to do so." & _"Then he may say once more, 'Truly the light is sweet, and what a pleasant thing it is for the eyes to see the sun.'" - The Day the Earth Caught Fire Link to comment Share on other sites More sharing options...
Valik Posted January 10, 2006 Share Posted January 10, 2006 i can't think of a language that lets you make 1 assignment to 2 variables in the same expression the way you have it there.If you use SciTE, then you use Lua (indirectly) and it supports multiple return values with a similar syntax. Link to comment Share on other sites More sharing options...
seandisanti Posted January 10, 2006 Share Posted January 10, 2006 If you use SciTE, then you use Lua (indirectly) and it supports multiple return values with a similar syntax.ah, i stand corrected then. i've never used that language or read anything about it. seems like it would make for some confusing code... Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted January 10, 2006 Moderators Share Posted January 10, 2006 Well, I'd like to see an example of it personally... That could come in quite handy!! Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
Valik Posted January 10, 2006 Share Posted January 10, 2006 Well, I'd like to see an example of it personally... That could come in quite handy!!Here's a LUA call to one of the built-in methods which returns the start and end positions of the regular expression capture as well as the capture itself: local from, to, name = string.find(line, "[Ff][Uu][Nn][Cc][%s]*([%w_]*)") I don't have any code off-hand showing multiple values being returned from a function I wrote. Link to comment Share on other sites More sharing options...
seandisanti Posted January 10, 2006 Share Posted January 10, 2006 Here's a LUA call to one of the built-in methods which returns the start and end positions of the regular expression capture as well as the capture itself: local from, to, name = string.find(line, "[Ff][Uu][Nn][Cc][%s]*([%w_]*)") I don't have any code off-hand showing multiple values being returned from a function I wrote.thanks for the example, i don't think that's a language i'm going to be getting into any time soon. Link to comment Share on other sites More sharing options...
Valik Posted January 10, 2006 Share Posted January 10, 2006 LUA is a very simple language. It's probably just a bit easier than AutoIt. Link to comment Share on other sites More sharing options...
seandisanti Posted January 10, 2006 Share Posted January 10, 2006 LUA is a very simple language. It's probably just a bit easier than AutoIt.i dunno, you guys have made autoit pretty easy for us... what's the main intended purpose for lua? i mean like autoit is for windows interaction, perl is aimed at text manipulation (i know it can do alot more than that, but that's where i was told it's real strengths are) etc Link to comment Share on other sites More sharing options...
BigDod Posted January 10, 2006 Share Posted January 10, 2006 i dunno, you guys have made autoit pretty easy for us... what's the main intended purpose for lua? i mean like autoit is for windows interaction, perl is aimed at text manipulation (i know it can do alot more than that, but that's where i was told it's real strengths are) etcIf you are interested you can find out all about it Here Time you enjoyed wasting is not wasted time ......T.S. Elliot Suspense is worse than disappointment................Robert Burns God help the man who won't help himself, because no-one else will...........My Grandmother Link to comment Share on other sites More sharing options...
Valik Posted January 10, 2006 Share Posted January 10, 2006 Lua is a good language for embedding into applications like SciTE. It's also used in a lot of games. Link to comment Share on other sites More sharing options...
seandisanti Posted January 10, 2006 Share Posted January 10, 2006 If you are interested you can find out all about it HereLua is a good language for embedding into applications like SciTE. It's also used in a lot of games.thanks guys, i think i'll take a look at it when i get home, but i don't see myself getting into it much... I've been able to accomplish everything i've needed to with autoit, java, vb, or some combination thereof. occaisonally i'll pick up other languages just to have them on the resume (this may be one of those cases) but those 3 are the ones i use on the most regular basis. 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