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: 2028
Joined: Sun Sep 23, 2007 4:58 pm

Re: Can a function return two values?

Post by SparkOut » 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.

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

Re: Can a function return two values?

Post by Klaus » Thu Jan 31, 2019 9:15 pm


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

Re: Can a function return two values?

Post by SparkOut » Thu Jan 31, 2019 9:27 pm

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

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

Re: Can a function return two values?

Post by bogs » Thu Jan 31, 2019 9:45 pm

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

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

Re: Can a function return two values?

Post by FourthWorld » Thu Jan 31, 2019 10:46 pm

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.
Richard Gaskin
Community volunteer LiveCode Community Liaison

LiveCode development, training, and consulting services: Fourth World Systems: http://FourthWorld.com
LiveCode User Group on Facebook : http://FaceBook.com/groups/LiveCodeUsers/

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

Re: Can a function return two values?

Post by dunbarx » Thu Jan 31, 2019 11:19 pm

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
   answer the result
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
VIP Livecode Opensource Backer
Posts: 5138
Joined: Sat Apr 08, 2006 8:31 pm
Location: Minneapolis MN
Contact:

Re: Can a function return two values?

Post by jacque » Fri Feb 01, 2019 6:32 pm

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

Post Reply

Return to “Talking LiveCode”