start using stack in standalone

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

Moderators: Klaus, FourthWorld, heatherlaine, kevinmiller, robinmiller

Post Reply
neville
Posts: 36
Joined: Tue Apr 15, 2008 8:37 am

start using stack in standalone

Post by neville » Thu Dec 07, 2017 5:37 am

I have a standalone (Mac OS X High Sierra, livecode 8.1.8 ) - let's call it "myApp" which opens a data stack "myData". In myData I call
start using stack "myApp"

and myApp certainly appears in the stacksinuse.

All works fine in the development environment, but in the standalone *sometimes --- I think only from menus* calls to functions in myApp from myData just cause the myData script to exit to top, with no error messages (eg if I put in a try-catch statement).

If I wrap the calls to myApp in a
push cd ; go to stack myApp; call-the-function; pop cd
wrapper it works; but this is not a tenable solution or work-around.

It all used to work, and I am tearing my hair out after 4 days of grappling with this.

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

Re: start using stack in standalone

Post by bogs » Thu Dec 07, 2017 4:35 pm

This is not an answer to your question so much, but curiosity on my part.
neville wrote:
Thu Dec 07, 2017 5:37 am
but in the standalone *sometimes --- I think only from menus* calls to functions in myApp from myData just cause the myData script to exit to top
How did you test this out? Did you try putting answer breaks for the standalone to determine when the event was firing? Or does it just seem as if the same function call from something other than the menu works?

Is the code that is not in the menu calling the particular function the same as the code in the menu routine? If not, then you may have an issue in the menu routine, after all, if it is working else where in the program, then it is working.

Still waking up, if the above was meaningless, crucify me after my first cup of coffee Image
ImageImage

neville
Posts: 36
Joined: Tue Apr 15, 2008 8:37 am

Re: start using stack in standalone

Post by neville » Thu Dec 07, 2017 10:22 pm

Yes. I have a custom alert in the library (myApp) which fires if called from myData except if called from the menu scripts. This is probably the main reason I don't want to use the workaround of going to myApp to call the alert, I want the alert to show on top of the myData window; for other calls to myApp I could lock the screen, go to myApp, execute the handler there, and come back to myData. Of course I'd rather it worked properly.

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

Re: start using stack in standalone

Post by jacque » Fri Dec 08, 2017 12:30 am

The handler could be erroring and aborting rather than exiting to top. You might be able to track the problem more easily it you put an answer dialog into the function in myApp that reports the executionContexts, or even just notifies you that it actually ran to the end.

You could also include the Remote Debugging inclusion in your standalone temporarily. That would allow you to debug the script normally as though you were in the IDE, and you could trace through the scripts and see what's going on. I can't remember now if Remote Debugging is in the free Community version; you may need Indy to use it.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

neville
Posts: 36
Joined: Tue Apr 15, 2008 8:37 am

Re: start using stack in standalone

Post by neville » Fri Dec 08, 2017 1:16 am

Thanks. I have been doing that (or equivalent, with my own logging routines). And yes, maybe aborting rather than exit to top, but that's essentially equivalent - except that abort should produce an error message I would have thought. An actual crash might be more informative.

I guess I must have a syntax error somewhere in my (very large :cry: ) library stack, which the development environment tolerates but the standalone doesn't (but only when called from another stack rather than within the same stack -- and then only sometimes -- which seems weird).

I'll try reordering my handlers in the library to find the one that fails: I believe I am correct in thinking that handlers *before* the syntax error should perform correctly.

neville
Posts: 36
Joined: Tue Apr 15, 2008 8:37 am

Re: start using stack in standalone

Post by neville » Fri Dec 08, 2017 1:32 am

Hmm, the "weird" bit above about whether called from within the stack or outside. The defaultStack is different in those two cases! That may be the clue I need.

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

Re: start using stack in standalone

Post by jacque » Fri Dec 08, 2017 2:46 am

In the IDE you get an error message, but in standalones errors fail silently. If you want the error reported you can either check the result, use a try structure, or to catch them all, use an errorDialog handler. ErrorDialog handlers are what the IDE uses to report errors.

The IDE translates the error codes for you but you'll need to look them up in a standalone. There's a tool for that in the user examples, search for "Error lookup" to find it.

If your function assumes the current stack is the app mainstack, then that could explain the problem. It's worth looking into.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

neville
Posts: 36
Joined: Tue Apr 15, 2008 8:37 am

Re: start using stack in standalone

Post by neville » Fri Dec 08, 2017 4:20 am

Solved.

I recompiled with LC7.1.3. Here the workaround I installed for LC8 now doesn't work in the development environment, let alone the standalone! But it does throw an error, saying the remote handler (which is in the script of myApp) cannot be found when I explicitly go to the stack myApp, while it *is* found if I do *not* go to myApp. Clearly the message path is wrong (well, not what I wanted). Which points to the culprit.

I mentioned my stack is very large; it is also very old, in fact inherited from HyperCard. Which means its dynamicPaths was set to true. Turning this off made the stack behave itself.

Perhaps this is not likely to bite post-diluvian scripters, but it still worth noting that
. LC 8 behaves differently from LC7 in its message path behaviour in the development environment, and its behaviour in a standalone is not quite the same as in the development environment, at least as regards its treatment of the dynamicPaths setting
. LC standalone should give a "handler not found" error when aborting a script even if it does continue to run gracefully (maybe it does but I couldn't find it either by using a try-catch statement or looking at the Console logs)

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

Re: start using stack in standalone

Post by jacque » Fri Dec 08, 2017 4:43 am

I'm glad you found it. Readers should note that this difference will likely only be seen in converted HC stacks. LC 7 also broke HC imports.

I think you might have caught the error with an errorDialog handler too, but the main thing is it's solved now. :-)
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

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

Re: start using stack in standalone

Post by bogs » Fri Dec 08, 2017 4:48 am

Yah, congratulations, I'm glad you figured it out as well.
ImageImage

Post Reply

Return to “Talking LiveCode”