Using return in a command script

classic Classic list List threaded Threaded
23 messages Options
12
Reply | Threaded
Open this post in threaded view
|

Using return in a command script

Bob Sneidar-2
I could have sworn that issueing return and a value sets the result to that value. This is no longer the case. I can work around it, but I've been hours troubleshooting only to discover I'm not passing values in comaands.

Bob S



_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|

Re: Using return in a command script

dunbarxx
This post was updated on .
Bob.

Do you mean something like this does not work anymore???

Impossible. Or rather, say it ain't so.

on mouseUp
   doThis
   answer the result
end mouseUp

on doThis
   return random(999)
end doThis
Reply | Threaded
Open this post in threaded view
|

Re: Using return in a command script

Richard Gaskin
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
  ____________________________________________________________________
  [hidden email]                http://www.FourthWorld.com

_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|

Re: Using return in a command script

Mike Kerner
Are you using return for value and return for error?

return x for value
return x for error

On Wed, Oct 26, 2016 at 2:44 PM, Richard Gaskin <[hidden email]>
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
>  ____________________________________________________________________
>  [hidden email]                http://www.FourthWorld.com
>
>
> _______________________________________________
> use-livecode mailing list
> [hidden email]
> Please visit this url to subscribe, unsubscribe and manage your
> subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode
>



--
On the first day, God created the heavens and the Earth
On the second day, God created the oceans.
On the third day, God put the animals on hold for a few hours,
   and did a little diving.
And God said, "This is good."
_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|

Re: Using return in a command script

Bob Sneidar-2
In reply to this post by Richard Gaskin
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 <[hidden email]> 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
> ____________________________________________________________________
> [hidden email]                http://www.FourthWorld.com
>
> _______________________________________________
> use-livecode mailing list
> [hidden email]
> Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode


_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|

Re: Using return in a command script

Phil Davis-5
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 <[hidden email]> 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
>> ____________________________________________________________________
>> [hidden email]                http://www.FourthWorld.com
>>
>> _______________________________________________
>> use-livecode mailing list
>> [hidden email]
>> Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
>> http://lists.runrev.com/mailman/listinfo/use-livecode
>
> _______________________________________________
> use-livecode mailing list
> [hidden email]
> 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
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|

Re: Using return in a command script

Phil Davis-5
Never mind. I just created a test stack in 8.1.1 where the calling
handler always received 'false' from the 'doIt' command.

I tried making 'doIt' return:
false
"false"
(x = 0) -- after adding 1 to x

They all worked!
Maybe something else is interfering with your outcomes?

Phil



On 10/26/16 12:57 PM, Phil Davis 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
>>> <[hidden email]> 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
>>> ____________________________________________________________________
>>> [hidden email] http://www.FourthWorld.com
>>>
>>> _______________________________________________
>>> use-livecode mailing list
>>> [hidden email]
>>> Please visit this url to subscribe, unsubscribe and manage your
>>> subscription preferences:
>>> http://lists.runrev.com/mailman/listinfo/use-livecode
>>
>> _______________________________________________
>> use-livecode mailing list
>> [hidden email]
>> 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
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|

Re: Using return in a command script

Mike Kerner
In reply to this post by Phil Davis-5
well, in 8.1.1, anyway,

*on* mouseUp
b
*answer* the result
*end* mouseUp

*on* b
*return* false
*end* b


answers "false"

On Wed, Oct 26, 2016 at 3:57 PM, Phil Davis <[hidden email]> 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 <[hidden email]>
>>> 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
>>> ____________________________________________________________________
>>> [hidden email]                http://www.FourthWorld.com
>>>
>>> _______________________________________________
>>> use-livecode mailing list
>>> [hidden email]
>>> Please visit this url to subscribe, unsubscribe and manage your
>>> subscription preferences:
>>> http://lists.runrev.com/mailman/listinfo/use-livecode
>>>
>>
>> _______________________________________________
>> use-livecode mailing list
>> [hidden email]
>> 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
> [hidden email]
> Please visit this url to subscribe, unsubscribe and manage your
> subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode
>



--
On the first day, God created the heavens and the Earth
On the second day, God created the oceans.
On the third day, God put the animals on hold for a few hours,
   and did a little diving.
And God said, "This is good."
_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|

Re: Using return in a command script

mwieder
In reply to this post by Bob Sneidar-2
Works here in 8.1.1.

on mouseUp
  grunt
  put the result after msg
end mouseUp

on grunt
  return false
end grunt
--
 Mark Wieder
 ahsoftware@gmail.com
Reply | Threaded
Open this post in threaded view
|

Re: Using return in a command script

Richard Gaskin
In reply to this post by Bob Sneidar-2
Bob Sneidar wrote:

 >> On Oct 26, 2016, at 11:44 , Richard Gaskin 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.
 >
 > 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.

Works here in v8.1.1 RC1.

--
  Richard Gaskin
  Fourth World Systems
  Software Design and Development for the Desktop, Mobile, and the Web
  ____________________________________________________________________
  [hidden email]                http://www.FourthWorld.com

_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|

Re: Using return in a command script

Bob Sneidar-2
In reply to this post by Phil Davis-5
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 <[hidden email]> 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 <[hidden email]> 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
>>> ____________________________________________________________________
>>> [hidden email]                http://www.FourthWorld.com
>>>
>>> _______________________________________________
>>> use-livecode mailing list
>>> [hidden email]
>>> Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
>>> http://lists.runrev.com/mailman/listinfo/use-livecode
>>
>> _______________________________________________
>> use-livecode mailing list
>> [hidden email]
>> 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
> [hidden email]
> Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode


_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|

Re: Using return in a command script

Mike Kerner
just for the heck of it change the variable to a global so you can track it
inside and out of the handler, and see what happens.

On Wed, Oct 26, 2016 at 4:30 PM, Bob Sneidar <[hidden email]>
wrote:

> 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 <[hidden email]> 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 <[hidden email]>
> 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
> >>> ____________________________________________________________________
> >>> [hidden email]                http://www.FourthWorld.com
> >>>
> >>> _______________________________________________
> >>> use-livecode mailing list
> >>> [hidden email]
> >>> Please visit this url to subscribe, unsubscribe and manage your
> subscription preferences:
> >>> http://lists.runrev.com/mailman/listinfo/use-livecode
> >>
> >> _______________________________________________
> >> use-livecode mailing list
> >> [hidden email]
> >> 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
> > [hidden email]
> > Please visit this url to subscribe, unsubscribe and manage your
> subscription preferences:
> > http://lists.runrev.com/mailman/listinfo/use-livecode
>
>
> _______________________________________________
> use-livecode mailing list
> [hidden email]
> Please visit this url to subscribe, unsubscribe and manage your
> subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode
>



--
On the first day, God created the heavens and the Earth
On the second day, God created the oceans.
On the third day, God put the animals on hold for a few hours,
   and did a little diving.
And God said, "This is good."
_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|

Re: Using return in a command script

Bob Sneidar-2
Globals are fine if you only have one project open at a time. Otherwise you have to be careful to name all your globals to be specific to the stack which created them.

As I said, I am using properties to store persistent values these days. This way I can make portable cards or stacks I can add add to any project, and they won't walk on each other's "variables".

Bob S


On Oct 26, 2016, at 13:37 , Mike Kerner <[hidden email]<mailto:[hidden email]>> wrote:

just for the heck of it change the variable to a global so you can track it
inside and out of the handler, and see what happens.

_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|

Re: Using return in a command script

dunbarxx
In reply to this post by Bob Sneidar-2
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 <[hidden email]>
To: How to use LiveCode <[hidden email]>
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 <[hidden email]> 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 <[hidden email]> 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
>>> ____________________________________________________________________
>>> [hidden email]                http://www.FourthWorld.com
>>>
>>> _______________________________________________
>>> use-livecode mailing list
>>> [hidden email]
>>> Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
>>> http://lists.runrev.com/mailman/listinfo/use-livecode
>>
>> _______________________________________________
>> use-livecode mailing list
>> [hidden email]
>> 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
> [hidden email]
> Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode


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

_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|

Re: Using return in a command script

Mike Kerner
In reply to this post by Bob Sneidar-2
This is for testing and debugging it, Bob.  I'm not proposing that you
leave it as a global.

On Wed, Oct 26, 2016 at 4:56 PM, Bob Sneidar <[hidden email]>
wrote:

> Globals are fine if you only have one project open at a time. Otherwise
> you have to be careful to name all your globals to be specific to the stack
> which created them.
>
> As I said, I am using properties to store persistent values these days.
> This way I can make portable cards or stacks I can add add to any project,
> and they won't walk on each other's "variables".
>
> Bob S
>
>
> On Oct 26, 2016, at 13:37 , Mike Kerner <[hidden email]<mailto:
> [hidden email]>> wrote:
>
> just for the heck of it change the variable to a global so you can track it
> inside and out of the handler, and see what happens.
>
> _______________________________________________
> use-livecode mailing list
> [hidden email]
> Please visit this url to subscribe, unsubscribe and manage your
> subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode
>



--
On the first day, God created the heavens and the Earth
On the second day, God created the oceans.
On the third day, God put the animals on hold for a few hours,
   and did a little diving.
And God said, "This is good."
_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|

Re: Using return in a command script

Bob Sneidar-2
Oic. Well a global will definitely work. I seem to remember that native handlers like opencard/openstack automatically set the result to empty when they end successfully, which is likely my problem. I return a value at the end of an openCard handler and the handler immediately sets it to empty when it terminates.

Bob S


On Oct 26, 2016, at 14:59 , Mike Kerner <[hidden email]<mailto:[hidden email]>> wrote:

This is for testing and debugging it, Bob.  I'm not proposing that you
leave it as a global.

_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|

Re: Using return in a command script

Monte Goulding-2

> On 27 Oct. 2016, at 9:07 am, Bob Sneidar <[hidden email]> wrote:
>
> I return a value at the end of an openCard handler

What are you returning it to? openCard is sent by the engine… or are you calling it yourself?
_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|

Re: Using return in a command script

Bob Sneidar-2
I'll try to enumerate the process. I have an openStack handler in the card script of the mainstack. In this handler I initialize the app. First I insert my validations, utilities and front scripts into the message hierarchy. Then I attempt to register sqlyoga. If that succeeds, I go to a card called database setup.

This also has an openCard handler which attempts to connect to the registered database. If it is successful, I want to return true to the openCard handler on the first card, otherwise I want to return false. The reason is that the next step involves a login stack which queries the database for users and allows the user to login. I also query for settings. I cannot proceed until I know I have a good database connection.

I know it sounds convoluted, but I have some portable cards and stacks which function simply by including them in the mainstack, and then going to the card or stack. All of these cards/stacks are triggered by openCard/openStack handlers. I don't want the calling stack to actually call a handler on the target stacks. I want developers to simply go to those cards or stacks, which will populate properties of the mainstack with data that will be used later.

For example, the login stack will set properties in the mainstack called loginid, username and fullname which are used later by the settings card and every record added or updated will get the fullname in the updateby column, which every table I have has.

Now if I cannot connect to the database, then I haven't retrieved the settings and I haven't logged in, so I need to set some properties of the mainstack in the openCard handler of the mainstack so that when I do connect I can check those and force a login and settings update.

As I mentioned in a prior email, it's no big deal because I just work around it by setting properties instead of returning a value. It's just a gotcha to return a value in a built-in message handler if those handlers always set the result to empty.

Bob S


> On Oct 26, 2016, at 15:17 , Monte Goulding <[hidden email]> wrote:
>
>
>> On 27 Oct. 2016, at 9:07 am, Bob Sneidar <[hidden email]> wrote:
>>
>> I return a value at the end of an openCard handler
>
> What are you returning it to? openCard is sent by the engine… or are you calling it yourself?
> _______________________________________________
> use-livecode mailing list
> [hidden email]
> Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode

_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|

Re: Using return in a command script

Monte Goulding-2
OK, just to make sure I understand you I’ll summarise in code:

on openCard
   go card “database setup”
   if the result is false then
      — database setup failed
   end if
end openCard

— database setup card script
on openCard
   — do stuff
   return stuffFailed
end openCard

If ^ is what you are doing then no it won’t work. The result after the go command is an error message if it failed rather than anything returned by openCard.

Cheers

Monte

> On 27 Oct. 2016, at 10:19 am, Bob Sneidar <[hidden email]> wrote:
>
> I'll try to enumerate the process. I have an openStack handler in the card script of the mainstack. In this handler I initialize the app. First I insert my validations, utilities and front scripts into the message hierarchy. Then I attempt to register sqlyoga. If that succeeds, I go to a card called database setup.
>
> This also has an openCard handler which attempts to connect to the registered database. If it is successful, I want to return true to the openCard handler on the first card, otherwise I want to return false. The reason is that the next step involves a login stack which queries the database for users and allows the user to login. I also query for settings. I cannot proceed until I know I have a good database connection.
>
> I know it sounds convoluted, but I have some portable cards and stacks which function simply by including them in the mainstack, and then going to the card or stack. All of these cards/stacks are triggered by openCard/openStack handlers. I don't want the calling stack to actually call a handler on the target stacks. I want developers to simply go to those cards or stacks, which will populate properties of the mainstack with data that will be used later.
>
> For example, the login stack will set properties in the mainstack called loginid, username and fullname which are used later by the settings card and every record added or updated will get the fullname in the updateby column, which every table I have has.
>
> Now if I cannot connect to the database, then I haven't retrieved the settings and I haven't logged in, so I need to set some properties of the mainstack in the openCard handler of the mainstack so that when I do connect I can check those and force a login and settings update.
>
> As I mentioned in a prior email, it's no big deal because I just work around it by setting properties instead of returning a value. It's just a gotcha to return a value in a built-in message handler if those handlers always set the result to empty.
>
> Bob S
>
>
>> On Oct 26, 2016, at 15:17 , Monte Goulding <[hidden email]> wrote:
>>
>>
>>> On 27 Oct. 2016, at 9:07 am, Bob Sneidar <[hidden email]> wrote:
>>>
>>> I return a value at the end of an openCard handler
>>
>> What are you returning it to? openCard is sent by the engine… or are you calling it yourself?
>> _______________________________________________
>> use-livecode mailing list
>> [hidden email]
>> Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
>> http://lists.runrev.com/mailman/listinfo/use-livecode
>
> _______________________________________________
> use-livecode mailing list
> [hidden email]
> Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode


_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|

Re: Using return in a command script

Bob Sneidar-2
Thanks Monte. I've come to see that returning a value from a built in message handler is a no go.

Bob S


On Oct 26, 2016, at 16:36 , Monte Goulding <[hidden email]<mailto:[hidden email]>> wrote:

OK, just to make sure I understand you I’ll summarise in code:

on openCard
  go card “database setup”
  if the result is false then
     — database setup failed
  end if
end openCard

— database setup card script
on openCard
  — do stuff
  return stuffFailed
end openCard

If ^ is what you are doing then no it won’t work. The result after the go command is an error message if it failed rather than anything returned by openCard.

Cheers

Monte

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