Give me advice on how to debug

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

Post Reply
Mag
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 802
Joined: Fri Nov 16, 2012 10:51 pm

Give me advice on how to debug

Post by Mag » Sat Apr 19, 2014 6:40 pm

Hi all,

Please give me advice on how to debug a stack.

There is a main stack and a series of substacks, when I open the substack with this command:

Code: Select all

go to  stack theStackName as sheet
In develop mode the preOpenStack, openStack, openCard, preOpenCard, openControl works fine. In OS X standalone they are not trigged. :shock:

PS
Maybe I have to use Open stack instead of Go to stack? :oops:

jmburnod
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 2729
Joined: Sat Dec 22, 2007 5:35 pm
Contact:

Re: Give me advice on how to debug

Post by jmburnod » Sat Apr 19, 2014 7:16 pm

Hi Mag,

Check "sheet stack" in the LC dictionary

Best
https://alternatic.ch

Mag
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 802
Joined: Fri Nov 16, 2012 10:51 pm

Re: Give me advice on how to debug

Post by Mag » Sat Apr 19, 2014 7:28 pm

Thank you for posting jmburnod, unfortunately, no changes... Also removing the "as sheet" property didn't work. :oops:

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7393
Joined: Sat Apr 08, 2006 8:31 pm
Contact:

Re: Give me advice on how to debug

Post by jacque » Sat Apr 19, 2014 9:25 pm

Often if it looks like messages aren't being sent, what is really happening is that there is a script error somewhere that is aborting everything that follows. One way to find out if that's the case is to add an errorDialog handler to the stack script, and have it tell you if a script error occurs. Put this into the stack script:

Code: Select all

on errorDialog pErr
  answer "An error occured:" && pErr
end errorDialog
Errors will be returned as a series of cryptic numbers. If you look up "errorDialog" in the dictionary it explains what those numbers mean. Another way to look them up is to get the LiveCode Error Lookup stack from the User Samples area. You can type in the first number returned, and it will give you the same error description that the IDE does.

A fancier way to do the same thing is write the error to a text file on disk instead of using "answer." That lets you copy the error text and paste it into the multi-line lookup field in the Lookup stack. Usually a single error triggers a whole sequence of related errors, and seeing them all at once tells you the "chain of command" that is failing.

It's easier to see it than explain it. For most purposes, usually all you need to look up is the first number in the list on the top line, so "answer" is good enough.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

jmburnod
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 2729
Joined: Sat Dec 22, 2007 5:35 pm
Contact:

Re: Give me advice on how to debug

Post by jmburnod » Sat Apr 19, 2014 10:48 pm

Hi Mag,

I never used "sheet stack".
I just tested it with a substack and it works for me

You have to trap the preOpenStack, openStack, openCard messages in the substack script otherwise that is preOpenStack, openStack, openCard messages
in the main stack will be called

Best regards
Jean-Marc
Attachments
stTestsheetStack.livecode.zip
(944 Bytes) Downloaded 160 times
https://alternatic.ch

Mag
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 802
Joined: Fri Nov 16, 2012 10:51 pm

Re: Give me advice on how to debug

Post by Mag » Sun Apr 20, 2014 2:03 pm

Hi jmburnod, thank you so much. I tested your stack and works well, also in sandalone and with openCard message.

Hi jacque, thank you for your tips, it was just the thing I needed. I had the handler and in standalone (non in development mode) actually shows errors.

Now, I will try to learn what kind of errors are.
Attachments
Screen Shot 2014-04-20 at 2.50.59 PM.png

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7393
Joined: Sat Apr 08, 2006 8:31 pm
Contact:

Re: Give me advice on how to debug

Post by jacque » Sun Apr 20, 2014 6:13 pm

Okay, good. We read those lines from the bottom up. Each new error is put on top of the previous one. So in reverse order:

353: Name:
The compiler can't identify the exact problem, which is why the line number is zero, but there is something wrong with the name of something in the stack script
241: there's an error in the statement on line 559 in the preOpenStack handler
253: the error is in the if-then statement
246: there's an object in that line that can't be found
88: the object is a card referenced in that line

Since it works in the IDE and not in a standalone, the script may be looking for a card that exists only in the IDE. Or the card may be in a stack that isn't open or isn't in the message path.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

jmburnod
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 2729
Joined: Sat Dec 22, 2007 5:35 pm
Contact:

Re: Give me advice on how to debug

Post by jmburnod » Sun Apr 20, 2014 7:09 pm

Hi Mag
Did you put a preOpenStack and openStack messages in your substack ?
And if you have a preopencard or opencard messages in your main stack you have also to put a preopencard or opencard messages in your substack
https://alternatic.ch

Mag
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 802
Joined: Fri Nov 16, 2012 10:51 pm

Re: Give me advice on how to debug

Post by Mag » Mon Apr 21, 2014 1:27 pm

Hi jacque and Jean-Marc!

Thank you, with your help I solved the problem. It was a preOpenStack handle that was trigged every time I opened a substack (the problem appeared only when in standalone). I have lot of substacks so, to solve the problem, instead to put the preOpenStack in each of them, I put a if structure in main stack and now all works fine.

Code: Select all

if the short name of this stack is xyz then
--
end if
Thank you again!

Post Reply