Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

AppGameKit Classic Chat / Multiple returnvalues of a function

Author
Message
Increase
7
Years of Service
User Offline
Joined: 21st Feb 2017
Location:
Posted: 15th Apr 2017 20:40
I don't know how to access multiple return values of a function.

Say the function is :



then



Is there a syntax which makes this possible ?
PartTimeCoder
AGK Tool Maker
9
Years of Service
User Offline
Joined: 9th Mar 2015
Location: London UK
Posted: 15th Apr 2017 20:57
only if, thats one of the reasons I like Lua

you can return a user type, its a lot more work though



nz0
AGK Developer
17
Years of Service
User Offline
Joined: 13th Jun 2007
Location: Cheshire,UK
Posted: 15th Apr 2017 21:05
You could tokenise your return value.

Make the return value a tokenised string like "5,6,21,blah,201"

Your calling code can chop this up using the built-in token commands and take it from there.

Not elegant, but simple tho.
Phaelax
DBPro Master
21
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 15th Apr 2017 21:20
I've never known any language to return multiple values in such a way. What type of function are you needing this for? There's probably a better way to structure it.

Your other option is to create a UDT and return that.


"I like offending people, because I think people who get offended should be offended." - Linus Torvalds
MikeHart
AGK Bronze Backer
21
Years of Service
User Offline
Joined: 9th Jun 2003
Location:
Posted: 15th Apr 2017 21:29
Phaelax wrote: "I've never known any language to return multiple values in such a way."


LUA does this.
Running Windows 7 Home, 64 bit, 8 GB ram, Athlon II X2 255, ATI Radeon HD 4200. Using AGK2 Tier 1.
blink0k
Moderator
11
Years of Service
User Offline
Joined: 22nd Feb 2013
Location: the land of oz
Posted: 15th Apr 2017 23:57 Edited at: 16th Apr 2017 00:04
You could pass those values using REF and then when they are modified in the function they modify the passed values
nz0
AGK Developer
17
Years of Service
User Offline
Joined: 13th Jun 2007
Location: Cheshire,UK
Posted: 16th Apr 2017 00:27
^^ this. I forgot about that.. Should really start using that capability

Login to post a reply

Server time is: 2024-11-24 17:00:17
Your offset time is: 2024-11-24 17:00:17