Front script only runs when a breakpoint is set [SOLVED]

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

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
Emily-Elizabeth
Posts: 101
Joined: Mon Jan 03, 2022 7:10 pm

Front script only runs when a breakpoint is set [SOLVED]

Post by Emily-Elizabeth » Sun Mar 19, 2023 9:21 pm

I have the following code in a front script and it only runs successfully when a breakpoint is set. Has anyone seen this before and offer a workaround?

Code: Select all

on RawKeyDown key
  if (key = 65288) OR (key = 65535) then
      if (the selectedField <> EMPTY) AND (the cControlType of the selectedField <> "label") AND (the ShowWarningWhenDeletingARecord of stack "dbdPreferences") then
         answer "<p><b>Are you sure you want to delete this column?</b></p><p></p><p>This will delete the current column from the database and you cannot undo this action.</p>" with "Delete" or "Cancel" as sheet
         if (it is "Cancel") then
            exit RawKeyDown
         else
            pass RawKeyDown
         end if
      end if
   else
      pass RawKeyDown
   end if
 end RawKeyDown
Last edited by Emily-Elizabeth on Tue Mar 21, 2023 4:04 am, edited 1 time in total.

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10013
Joined: Wed May 06, 2009 2:28 pm

Re: Front script only runs when a breakpoint is set

Post by dunbarx » Sun Mar 19, 2023 9:36 pm

Emily.

Where is the breakpoint?

What happens when you do set one, say right at the beginning, and step through? Does the handler complete?

Craig

Emily-Elizabeth
Posts: 101
Joined: Mon Jan 03, 2022 7:10 pm

Re: Front script only runs when a breakpoint is set

Post by Emily-Elizabeth » Sun Mar 19, 2023 9:49 pm

Setting the breakpoint right at the beginning and stepping through it runs the code as it's supposed to be. Without the breakpoint nothing seems to happen, except that deletion of the field doesn't happen.
I'm using LiveCode 9.6.3 Community Edition

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10013
Joined: Wed May 06, 2009 2:28 pm

Re: Front script only runs when a breakpoint is set

Post by dunbarx » Mon Mar 20, 2023 4:18 am

Hmmm.

This should not happen, frontScript or whatever kind of script. I have had occasion where the same thing was seen; a handler would work fine if I stepped through it in the debugger, but not simply run normally.

These all resolved themselves, though sometimes I never knew how.

Maybe wait a day and try again? :roll:

Craig

Emily-Elizabeth
Posts: 101
Joined: Mon Jan 03, 2022 7:10 pm

Re: Front script only runs when a breakpoint is set

Post by Emily-Elizabeth » Mon Mar 20, 2023 3:40 pm

Yeah, I've waited, I've rebooted LiveCode, I tried in a standalone - the code doesn't run unless there is a breakpoint. :(

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10013
Joined: Wed May 06, 2009 2:28 pm

Re: Front script only runs when a breakpoint is set

Post by dunbarx » Mon Mar 20, 2023 4:47 pm

Emily.

So you have a stack configuration where this is a reliable, reproducible phenomenon? This is in the IDE, right?

Send it to Scotland at once.

Craig

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10013
Joined: Wed May 06, 2009 2:28 pm

Re: Front script only runs when a breakpoint is set

Post by dunbarx » Mon Mar 20, 2023 4:48 pm

Emily.

In a standalone the process just fails and stops?

Craig

bobcole
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 147
Joined: Tue Feb 23, 2010 10:53 pm

Re: Front script only runs when a breakpoint is set

Post by bobcole » Mon Mar 20, 2023 5:34 pm

The problem is in line 3. I commented out the third condition and it works.
Focus your attention on line 3.
Bob

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10013
Joined: Wed May 06, 2009 2:28 pm

Re: Front script only runs when a breakpoint is set

Post by dunbarx » Mon Mar 20, 2023 9:05 pm

Bob.

Is the third line:

if (the selectedField....
or
answer "<p><b>Are you sure you want to delete...

The second example above is a doozy.

Craig

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10013
Joined: Wed May 06, 2009 2:28 pm

Re: Front script only runs when a breakpoint is set

Post by dunbarx » Mon Mar 20, 2023 9:13 pm

Bob.

But whatever peculiarity you noticed in the line you mentioned, how does that impact the issue?

As I said, I have had several instances over the years where I see what Emily does. LC will step through a portion of a handler but not run through it. Just fooling around with the script, whatever that may have meant, but NOT necessarily rewriting anything, has always resolved the anomaly, and always within a matter of several minutes of fooling around.

Sometimes just trying a few times seemed to have cleared it up. Sometimes fooling around with a breakpoint did. Something just clicked somewhere.

Craig

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10013
Joined: Wed May 06, 2009 2:28 pm

Re: Front script only runs when a breakpoint is set

Post by dunbarx » Mon Mar 20, 2023 9:15 pm

Bob.

Me again.

Did you set a breakpoint here and there or just comment here and there? If the first, what did you notice about the composition of the line itself?

Craig

bobcole
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 147
Joined: Tue Feb 23, 2010 10:53 pm

Re: Front script only runs when a breakpoint is set

Post by bobcole » Mon Mar 20, 2023 10:45 pm

I commented out part of this line:

Code: Select all

if (the selectedField <> EMPTY) AND (the cControlType of the selectedField <> "label") then --AND (the ShowWarningWhenDeletingARecord of stack "dbdPreferences") then
The script worked subsequent to that edit.
Bob

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10013
Joined: Wed May 06, 2009 2:28 pm

Re: Front script only runs when a breakpoint is set

Post by dunbarx » Mon Mar 20, 2023 11:15 pm

Bob.

The part that you commented out seemed to be valid LC syntax. Whatever, if anything at all, was in that custom property, it would have returned empty, or false, whatever. It should not have just stopped.

And whether it was valid or not, this still begs the issue.

Craig

Emily-Elizabeth
Posts: 101
Joined: Mon Jan 03, 2022 7:10 pm

Re: Front script only runs when a breakpoint is set

Post by Emily-Elizabeth » Tue Mar 21, 2023 4:03 am

Commenting out the code didn't work for me, but changing selectedField to selectedObject worked

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10013
Joined: Wed May 06, 2009 2:28 pm

Re: Front script only runs when a breakpoint is set [SOLVED]

Post by dunbarx » Tue Mar 21, 2023 1:53 pm

I will take over the burden of crazy LC behavior, starting, now...

First off, glad that Emily has fixed the problem, though we have not fixed the problem, that is, why does stepping through a handler work, where running that handler not work.

Now then. I make a new stack in a new session. I pull a field from the tools palette, and make sure it does NOT have focus. From msg:

Code: Select all

answer the selectedField
I get "Field 3"

Craig

Post Reply

Return to “Talking LiveCode”