Squirrel

The programming language
Welcome to Squirrel Sign in | Join | Help
in Search

Return Multiple Variable in C++

Last post 10-02-2008, 1:44 PM by kog. 5 replies.
Sort Posts: Previous Next
  •  09-28-2008, 1:44 PM 2798

    Return Multiple Variable in C++

    Hello
    at beginning, my english is very bad, who anybody speaks german, please contact me.

    So, my question is, in Squirrel, i can return multiple variables,like this:

    function SquirrelFunc()
    {
      return 1,2
    }

    test,test2 = SquirrelFunc()

    is there any chance to make this in C++?
  •  09-28-2008, 3:05 PM 2799 in reply to 2798

    Re: Return Multiple Variable in C++

    Are you sure you understand the comma operator? The Squirrel code you posted isn't returning multiple values. When you have several expressions with commas between them, all the expressions are evaluated, but only the last one is returned.

    In Squirrel,

    return 1,2

    is exactly the same thing as:

    return 2

    Maybe I misunderstood you though. :-P Are you asking if multiple return values might be added to Squirrel in the future?
  •  09-28-2008, 3:08 PM 2800 in reply to 2799

    Re: Return Multiple Variable in C++

    hmm ***, i have it posted on the false Forum :/

    hmm i think, i have see like so in a code.. sry...
    is no chance to make this?
  •  10-02-2008, 1:58 AM 2808 in reply to 2800

    Re: Return Multiple Variable in C++

    I am also interested in returning multiple values. I have tried the same methods as LUA in C++ ( sq_push* 3 times and returning 3) but i cant seem to parse it in the squirrel script.

    Is it possible at all? If so, how?

    Thanks

  •  10-02-2008, 11:35 AM 2812 in reply to 2808

    Re: Return Multiple Variable in C++

    Squirrel, as a C-like language, only returns one value from a function...

    but you can always make that value a table and have multiple fields in it to carry (other) multiple values...  (you can also use an array for this purpose)
  •  10-02-2008, 1:44 PM 2813 in reply to 2812

    Re: Return Multiple Variable in C++

    Yes, i use now Arrays...

View as RSS news feed in XML
Powered by Community Server, by Telligent Systems