Sign in to follow this  
Followers 0
oldgeezer

Function Return parameters

13 posts in this topic

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?

Share this post


Link to post
Share on other sites



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

1100111 00001011101111 00011101101111 00010111100100 00001111110100 00110111110010 00101101111001 0011100i didn't make up this form of encryption, but i like it.credit to the lvl 6 challenge on arcanum.co.nz

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

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...

1100111 00001011101111 00011101101111 00010111100100 00001111110100 00110111110010 00101101111001 0011100i didn't make up this form of encryption, but i like it.credit to the lvl 6 challenge on arcanum.co.nz

Share this post


Link to post
Share on other sites

Well, I'd like to see an example of it personally... That could come in quite handy!!


[center]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.[/center]

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

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.

1100111 00001011101111 00011101101111 00010111100100 00001111110100 00110111110010 00101101111001 0011100i didn't make up this form of encryption, but i like it.credit to the lvl 6 challenge on arcanum.co.nz

Share this post


Link to post
Share on other sites

LUA is a very simple language. It's probably just a bit easier than AutoIt.

Share this post


Link to post
Share on other sites

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

1100111 00001011101111 00011101101111 00010111100100 00001111110100 00110111110010 00101101111001 0011100i didn't make up this form of encryption, but i like it.credit to the lvl 6 challenge on arcanum.co.nz

Share this post


Link to post
Share on other sites

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

If you are interested you can find out all about it Here


Get Beta versions Here Get latest SciTE editor Here AutoIt 1-2-3 by Valuater - A great starting point.

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

Share this post


Link to post
Share on other sites

Lua is a good language for embedding into applications like SciTE. It's also used in a lot of games.

Share this post


Link to post
Share on other sites

If you are interested you can find out all about it Here

Lua 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.


1100111 00001011101111 00011101101111 00010111100100 00001111110100 00110111110010 00101101111001 0011100i didn't make up this form of encryption, but i like it.credit to the lvl 6 challenge on arcanum.co.nz

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