LC can drive you nuts

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

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 9567
Joined: Wed May 06, 2009 2:28 pm
Location: New York, NY

LC can drive you nuts

Post by dunbarx » Thu Apr 22, 2021 6:53 pm

I have a mainStack and a subStack. In the middle of a handler in the mainStack I navigate to the substack. All of a sudden, after weeks of no issues, and though the navigation itself works fine, program flow ceases, as if I exited to top.

There was this in the subStack stack script:

Code: Select all

on closeStackRequest
   save  stack "shapes"
   close stack "shapes"
end closeStackRequest
I placed a breakpoint in that handler (as I did everywhere in the subStack) to try to see what might be firing in the substack. Nothing, ever. No breakpoint ever caught anything.

Commenting that handler out, however, fixed the issue. And when I made the handler whole again, no changes at all, the problem went away. It took me more than just a little while to ferret this out. I know life isn't perfect, but anyone ever see anything like this?

Craig

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 9249
Joined: Fri Feb 19, 2010 10:17 am
Location: Bulgaria

Re: LC can drive you nuts

Post by richmond62 » Thu Apr 22, 2021 7:05 pm

anyone ever see anything like this?
Sorry, busy trying to source some Lithium tablets (illegal in Bulgaria) . . . 8)

SparkOut
Posts: 2834
Joined: Sun Sep 23, 2007 4:58 pm

Re: LC can drive you nuts

Post by SparkOut » Thu Apr 22, 2021 8:32 pm

No but as a guess, is it hitting some recursion limit or something? Just as a thought, what if you change the

Code: Select all

close stack "shapes"
line to

Code: Select all

pass closeStackRequest

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 9567
Joined: Wed May 06, 2009 2:28 pm
Location: New York, NY

Re: LC can drive you nuts

Post by dunbarx » Thu Apr 22, 2021 9:16 pm

@Richmond.

Not a bad idea.

@Sparkout.

The handler never fired; no handler in the subStack ever did. That is the odd thing. Breakpoints in all card and stack handlers never caught anything, so I don't think it mattered what the actual code was in any of them.

Commenting and then uncommenting fixed it. Pure happenstance.

Craig

mwieder
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3581
Joined: Mon Jan 22, 2007 7:36 am
Location: Berkeley, CA, US
Contact:

Re: LC can drive you nuts

Post by mwieder » Fri Apr 23, 2021 2:22 am

I find that on the occasions when I have to paste something from an rtf file into the script editor, there are invisible characters where there should be empty lines, and these cause errors. I can backspace through them to delete them (seven IIRC - six spaces followed by an invisible backslash) or I can comment the line out and that also removes them. Thus uncommenting the empty line will act normally.

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 9567
Joined: Wed May 06, 2009 2:28 pm
Location: New York, NY

Re: LC can drive you nuts

Post by dunbarx » Fri Apr 23, 2021 4:36 am

Mark.

I am not so smug as to think that I have no invisible errors in my thinking and coding.

But I did not change the handler. I only placed a red dot at it, which did not catch anything. I then commented the whole with CMD-Dash, and then uncommented with SHIFT-CMD-Dash. Of course, this will not be the first time that things have "fixed" themselves on their own. Just life, I suppose.

Craig

mwieder
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3581
Joined: Mon Jan 22, 2007 7:36 am
Location: Berkeley, CA, US
Contact:

Re: LC can drive you nuts

Post by mwieder » Fri Apr 23, 2021 4:40 am

Craig-

Yes, note that I "fixed" the errant lines of code with invisible characters by commenting/uncommenting them as well.
Go figger. :roll:

SteveFI
Posts: 30
Joined: Tue Mar 16, 2021 6:15 pm

Re: LC can drive you nuts

Post by SteveFI » Fri Apr 23, 2021 3:06 pm

I know exactly how you mean about going nuts. I've come back to LC after being away for 10 years or so and have been making really good progress on some apps for work. I don't get regular time for them, so it's a few hours here, maybe as much as a day elsewhere. I'm enjoying it so much, I'm happy to throw some of my own time into it.

But today, I had a big head scratcher. A routine that constructs an output in rtf format and then draws lines over the top to signify totals and subtotals would stop drawing graphics once it got to the 26th (there are 50 in total). Even more inexplicably, graphics 27 to 50 would draw over the top of the 26th.

I read up on formattedRect, rewrote code to control the dimensions of the field and the group it's all in (which handles resizing and factors tab widths), trawled the forums and even outputted progress on what it was doing to a field. After walking away, making a cup of tea and returning, I spotted the wrong variable in a line. I'd looked over the code umpteen times.

What does impress me is how awesome the language is. So many times I've gone to do something, have a little read up in the dictionary on a key word I remembered, spot another related word and find an even better way to do something.

mwieder
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3581
Joined: Mon Jan 22, 2007 7:36 am
Location: Berkeley, CA, US
Contact:

Re: LC can drive you nuts

Post by mwieder » Fri Apr 23, 2021 4:51 pm

Yep. As they say, the language gives you enough rope to shoot yourself in the foot. And if you didn't know you could do that, you should have read the manual.

I've often found the best way to deal with a gnarly problem is to step away and go do something else for a while. Solutions will come to me when I'm pulling weeds in the garden or taking a shower or driving somewhere and thinking of something else.

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 9249
Joined: Fri Feb 19, 2010 10:17 am
Location: Bulgaria

Re: LC can drive you nuts

Post by richmond62 » Fri Apr 23, 2021 4:56 pm

Solutions will come to me when I'm pulling weeds in the garden or taking a shower or driving somewhere and thinking of something else.
Words of true wisdom.

Personally I tend to draw a hot bath and soak while listening to some Baroque music and a glass of semi-decent wine.

https://youtu.be/zja9ANxZ4Ko

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 9567
Joined: Wed May 06, 2009 2:28 pm
Location: New York, NY

Re: LC can drive you nuts

Post by dunbarx » Fri Apr 23, 2021 5:17 pm

Richmond.

Really.

I did not open the link, but I so hope it was not a video of you taking a bath, whatever the temperature of the water. :shock:

Craig

kdjanz
Posts: 300
Joined: Fri Dec 09, 2011 12:12 pm
Location: Fort Saskatchewan, AB Canada

Re: LC can drive you nuts

Post by kdjanz » Fri Apr 23, 2021 5:54 pm

No Craig.

It was a baroque music concert - Hayden Organ concerto. Good taste, but a bit over the top for my taste.

All good here and safe for the kiddies.

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 9567
Joined: Wed May 06, 2009 2:28 pm
Location: New York, NY

Re: LC can drive you nuts

Post by dunbarx » Fri Apr 23, 2021 6:12 pm

Nuts.

The issue has re-emerged again today. As before, with this in the stack script of a substack:

Code: Select all

on closeStackRequest
   save  stack "shapes"
   close stack "shapes"
end closeStackRequest
A handler in the mainStack that navigates to that subStack will indeed go there, but then execution stops at that line. However:

1- If the subStack is already open, then the mainStack handler works just fine all the way to its end.
2- If I comment out the above subStack handler, then the mainStack handler works just fine all the way to its end.

I have ways around this, I just don't get it. What on earth has a closeStackRequest in a subStack have to do with the mainStack handler? Did I mention that a breakpoint in the closeStackRequest never fires?

A brand new stack/substack with a navigation handler in the mainStack and the above handler in the substack works just fine. I am not surprised, just nuts.

So there is something about my project stacks. Shocking, I know. But how do I find out what, if no breakpoint ever fires? In other words, what is the difference between a handler that is never used, and a handler that does not exist at all? How do it know?

Craig

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 9249
Joined: Fri Feb 19, 2010 10:17 am
Location: Bulgaria

Re: LC can drive you nuts

Post by richmond62 » Fri Apr 23, 2021 7:05 pm

Craig, not wanting to disappoint you . . .
-
elephant-bathtub-pours-water-over-himself-rubbing-sponge-bath-time-isolated-191317061.jpeg

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 9801
Joined: Sat Apr 08, 2006 7:05 am
Location: Los Angeles
Contact:

Re: LC can drive you nuts

Post by FourthWorld » Fri Apr 23, 2021 7:28 pm

Do you have a simple sample stack that would allow us to see the issue here?
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

Post Reply

Return to “Talking LiveCode”