Suggestion: function - return multiple values

Discussion and feedback on Construct 2

Post » Tue Aug 20, 2013 10:58 am

Hello there,

It would be very usefull to be able to return multiple values in a function and adress them with indexes like parameters.

What do you think?
B
45
S
11
G
4
Posts: 517
Reputation: 7,393

Post » Tue Aug 20, 2013 12:47 pm

You could return a string with comma-separated numbers, or simply make the function set values in an array instead of returning a value (which doesn't work with recursive functions, but might work for you).
Scirra Founder
B
397
S
236
G
88
Posts: 24,423
Reputation: 194,560

Post » Tue Aug 20, 2013 6:09 pm

Look up TokenAt() I use that all the time.

TokenAt("1,2,3,4",2,",") = 3

the selected comma separated item in the list is 3.

Edit: Actually here is the manual entries:
tokenat(src, index, separator)
Return the Nth token from src, splitting the string by separator. For example, tokenat("apples|oranges|bananas", 1, "|") returns oranges.

tokencount(src, separator)
Count how many tokens occur in src using separator. For example, tokencount("apples|oranges|bananas", "|") returns 3.Paradox2013-08-20 18:16:48
B
233
S
62
G
33
Posts: 902
Reputation: 40,398

Post » Tue Aug 20, 2013 7:17 pm

Yes, the string will do the job.
B
45
S
11
G
4
Posts: 517
Reputation: 7,393


Return to Construct 2 General

Who is online

Users browsing this forum: Euduardo and 14 guests