ender13 Posted August 24, 2006 Share Posted August 24, 2006 What is the syntax for returning multiple variables from a function? I know i coudl use an Array, but that seems a little over done for just 3 variables. I tried using return($var1, $var2, $var3), but the syntax was wrong. I can't seem to find anything in the help files. Thanks, Link to comment Share on other sites More sharing options...
Joon Posted August 24, 2006 Share Posted August 24, 2006 (edited) I'm not an expert but I thought Function returns one value(variable) in general programming. You could use Global variable to set it while in Function though. Edited August 24, 2006 by Joon Link to comment Share on other sites More sharing options...
sandyd Posted August 24, 2006 Share Posted August 24, 2006 You could always return an array variable that could hold the multiple values ----[ SandyD ]--- Link to comment Share on other sites More sharing options...
Helge Posted August 24, 2006 Share Posted August 24, 2006 I'm just wondering..How would expect to use that information returned by Return if that actually worked ? First of all Return isn't a function, but a keyword, so the syntax is ofcourse wrong. If you could show us some code which shows why you need this, maybe we could help you solve it. If you want it to return something like "var1 var2 var3", then you could just do it in a simple code like this :Return $var1 & " " & $var2 & " " & $var3 Link to comment Share on other sites More sharing options...
GaryFrost Posted August 24, 2006 Share Posted August 24, 2006 or pass them in ByRef and don't need to return anything or make global. SciTE for AutoItDirections for Submitting Standard UDFs Don't argue with an idiot; people watching may not be able to tell the difference. Link to comment Share on other sites More sharing options...
ender13 Posted August 24, 2006 Author Share Posted August 24, 2006 Figured it out. I ended up combinging the strings into one variable and returned that. Thanks Link to comment Share on other sites More sharing options...
Valik Posted August 24, 2006 Share Posted August 24, 2006 I'm just wondering..How would expect to use that information returned by Return if that actually workedPresumably the same way it works in Lua (Example code is Lua): var1, var2 = lua_function() print(var1 .. "\n") -- Prints 1 print(var2 .. "\n") -- Prints 2 function lua_function return 1, 2 end 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