how are variables passed from functions?

Jacques Hausser jacques.hausser at unil.ch
Fri Nov 14 12:02:41 EST 2014


Yes, it is ’the Result’, I just checked it - good hint, Dave ! didn’t think about that before…

Jacques

> Le 14 nov. 2014 à 17:56, Dave Cragg <dave.cragg at lacscentre.co.uk> a écrit :
> 
> Tiemo,
> 
> Interesting. It looks like functions return the value of "the result" in the absence of a return statement.
> 
> Other languages would probably return "void" or "null" or something similar, and we might expect Livecode to return "empty".
> 
> I've no opinion on whether it is a bug or not, but I think it is probably better to specifically return a value from a function. We don't always have control over what appears in "the result". 
> 
> Cheers
> Dave
> 
> 
> 
> On 14 Nov 2014, at 08:47, Tiemo Hollmann TB <toolbook at kestner.de> wrote:
> 
>> By accident I noticed that I don't have a return at a certain point of a
>> function but nevertheless the value was passed back without a return to the
>> calling handler.
>> 
>> I can reproduce the issue to this scenario:
>> 
>> 
>> 
>> --Btn script
>> 
>> on mouseUp
>> 
>>   put foo1() into myVar1 -- I get the value "Test"           
>> 
>> end mouseUp
>> 
>> 
>> 
>> --script in stack
>> 
>> function foo1
>> 
>>  put foo2() into myVar2 -- no return in this function
>> 
>> end foo1
>> 
>> 
>> 
>> function foo2
>> 
>>  return "Test" -- return here in second level
>> 
>> end foo2
>> 
>> 
>> 
>> Up to now I thought that every function has to have a return statement if
>> you want anything getting back.
>> 
>> Can somebody explain to me what is going on here? How is the value from
>> function foo2 passed back to the mouseup handler, even with different var
>> names?
>> 
>> Is this a bug or just an accident or even wanted?
>> 
>> Thanks for enlightening
>> 
>> Tiemo





More information about the use-livecode mailing list