## Can a function return two values?

Anything beyond the basics in using the LiveCode language. Share your handlers, functions and magic here.

Moderators: Klaus, FourthWorld, heatherlaine, robinmiller, kevinmiller

SparkOut
Posts: 2020
Joined: Sun Sep 23, 2007 4:58 pm

### Re: Can a function return two values?

At a tangent, I was wondering where I could find an (old) article by (IIRC) Richard (Fourth World) concerning a technique to return a value from a function as well as specific value in "the result". I am at a loss to track it down.

Klaus
Posts: 11197
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

### Re: Can a function return two values?

SparkOut
Posts: 2020
Joined: Sun Sep 23, 2007 4:58 pm

### Re: Can a function return two values?

Well, yes. But not successful in tracking it down. I am not even certain, but I think Richard was the author.

bogs
Posts: 3787
Joined: Sat Feb 25, 2017 10:45 pm

### Re: Can a function return two values?

Did you check in the journal? If it isn't there, you might find it in his revNet plugin...
GoRev(Livecode)Net plugin...
or in the number of tutorials he had in a much older version of RR...
Transcript WWWWhhhhaaa....?
or possibly in this stack...
Meta-fan-tabulous!
or my last guess, the scripting conferences?

FourthWorld
VIP Livecode Opensource Backer
Posts: 6833
Joined: Sat Apr 08, 2006 7:05 am
Location: Los Angeles
Contact:

### Re: Can a function return two values?

SparkOut wrote:
Thu Jan 31, 2019 9:12 pm
At a tangent, I was wondering where I could find an (old) article by (IIRC) Richard (Fourth World) concerning a technique to return a value from a function as well as specific value in "the result". I am at a loss to track it down.
That may have been an either/or, as in being able to return a value from a command with "the result". If I'd written that a function can do both I don't recall what it is. And if I did, since apparently it's not easy to remember I don't think I'd recommend it even if I knew what it was.

An array seems simplest for the OP's use case.
Community volunteer LiveCode Community Liaison

LiveCode development, training, and consulting services: Fourth World Systems: http://FourthWorld.com

dunbarx
VIP Livecode Opensource Backer
Posts: 6160
Joined: Wed May 06, 2009 2:28 pm
Location: New York, NY

### Re: Can a function return two values?

You may be referring to the ability of a command handler, as opposed to a function handler, to return a result.

The difference is that the control structure "return" puts a value into "the result" whereas in a function handler, return, er, returns a value.

Code: Select all

``````on mouseUp
resultTest
end mouseUp

on resultTest
repeat with y = 1 to 10
if y = 5 then return random(99)
end repeat
end resultTest``````
Craig Newman
Last edited by dunbarx on Fri Feb 01, 2019 9:11 pm, edited 1 time in total.

jacque
VIP Livecode Opensource Backer
Posts: 5104
Joined: Sat Apr 08, 2006 8:31 pm
Location: Minneapolis MN
Contact:

### Re: Can a function return two values?

mwieder wrote:
Thu Jan 31, 2019 5:05 pm
I regularly use numtochar(3) as a delimiter when I need something that is guaranteed to be unprintable.
Me too, and also numtochar(8) as a secondary delimiter. No one can put those into text when typing.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com