Using return in a command script

dunbarx at aol.com dunbarx at aol.com
Wed Oct 26 18:00:06 EDT 2016


The result is more ephemeral than "it". Do not rely on such a thing for very long, especially if you are doing stuff like changing cards and running handlers. The result may have been modified dozens of times along the way.


Craig



-----Original Message-----
From: Bob Sneidar <bobsneidar at iotecdigital.com>
To: How to use LiveCode <use-livecode at lists.runrev.com>
Sent: Wed, Oct 26, 2016 4:32 pm
Subject: Re: Using return in a command script

Very odd. Doesn't matter if I enclose in quotes I get the same result, only now I am seeing that if I call the handler that returns the value from the message box it works fine! So here's what I am trying to do. When I open a stack for the first time, I go to a Database Setup card. This card has an Opencard handler that handles the database initialization for the stack. If it's the first time there, I call a handler which stores a value in a script local variable, so the next time I open the Database Setup card for that session, I don't go through the whole Database Initialization all over again. 

Now if the initialization succeeds, I store true to a variable otherwise I store false. The last thing I do on the Opencard handler for the Database Setup card is I return the variable. If I put the result then breakpoint right after I return from that handler the result is empty!!! 

Clearly something in this process is setting the result to empty, and it probably has something to do with the navigation between cards. What I am doing instead is saving the value as a property of the mainstack, which I am doing more and more these days as a way of storing persistent values whose scope is the mainstack I am working with. Globals won't work because I often use a device like the database setup card in multiple projects which might be open simultaneously, and I don't want to walk on another stacks variables. 

So the exercise is academic I suppose. I'm sure that if I used return in a command that didn't actually go anywhere when I returned from it, the method would work fine. It just seems that using return in a command structure is fraught with peril, so I will just use object/card/stack properties instead. 

Bob S


> On Oct 26, 2016, at 12:57 , Phil Davis <revdev at pdslabs.net> wrote:
> 
> What happens if you return "false" instead of false? Still broken?
> Phil Davis
> 
> 
> On 10/26/16 12:45 PM, Bob Sneidar wrote:
>> I'm using version 8.1.1 (I don't distribute apps compiled with a dev preview). I return false and immediately in the calling script check for the result. It is empty.
>> 
>> Bob S
>> 
>> 
>>> On Oct 26, 2016, at 11:44 , Richard Gaskin <ambassador at fourthworld.com> wrote:
>>> 
>>> dunbarx wrote:
>>>> Do you mean something like this does not work anymore???
>>>> 
>>>> Impossible.
>>>> 
>>>> on mouseUp
>>>>   doThis
>>>>   answer the result
>>>> end mouseUp
>>>> 
>>>> on doThis
>>>>   return random(999)
>>>> end doThis
>>> Works here as of v9.0 dp 1.
>>> 
>>> -- 
>>> Richard Gaskin
>>> Fourth World Systems
>>> Software Design and Development for the Desktop, Mobile, and the Web
>>> ____________________________________________________________________
>>> Ambassador at FourthWorld.com                http://www.FourthWorld.com
>>> 
>>> _______________________________________________
>>> use-livecode mailing list
>>> use-livecode at lists.runrev.com
>>> Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
>>> http://lists.runrev.com/mailman/listinfo/use-livecode
>> 
>> _______________________________________________
>> use-livecode mailing list
>> use-livecode at lists.runrev.com
>> Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
>> http://lists.runrev.com/mailman/listinfo/use-livecode
>> 
> 
> -- 
> Phil Davis
> 
> 
> _______________________________________________
> use-livecode mailing list
> use-livecode at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode


_______________________________________________
use-livecode mailing list
use-livecode at lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode




More information about the use-livecode mailing list