Jump to content

Returning Multiple Variables


Recommended Posts

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

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

I'm just wondering..How would expect to use that information returned by Return if that actually worked

Presumably 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

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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...