Page 1 of 1
Front script only runs when a breakpoint is set [SOLVED]
Posted: Sun Mar 19, 2023 9:21 pm
by Emily-Elizabeth
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
Re: Front script only runs when a breakpoint is set
Posted: Sun Mar 19, 2023 9:36 pm
by dunbarx
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
Re: Front script only runs when a breakpoint is set
Posted: Sun Mar 19, 2023 9:49 pm
by Emily-Elizabeth
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
Re: Front script only runs when a breakpoint is set
Posted: Mon Mar 20, 2023 4:18 am
by dunbarx
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?
Craig
Re: Front script only runs when a breakpoint is set
Posted: Mon Mar 20, 2023 3:40 pm
by Emily-Elizabeth
Yeah, I've waited, I've rebooted LiveCode, I tried in a standalone - the code doesn't run unless there is a breakpoint.

Re: Front script only runs when a breakpoint is set
Posted: Mon Mar 20, 2023 4:47 pm
by dunbarx
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
Re: Front script only runs when a breakpoint is set
Posted: Mon Mar 20, 2023 4:48 pm
by dunbarx
Emily.
In a standalone the process just fails and stops?
Craig
Re: Front script only runs when a breakpoint is set
Posted: Mon Mar 20, 2023 5:34 pm
by bobcole
The problem is in line 3. I commented out the third condition and it works.
Focus your attention on line 3.
Bob
Re: Front script only runs when a breakpoint is set
Posted: Mon Mar 20, 2023 9:05 pm
by dunbarx
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
Re: Front script only runs when a breakpoint is set
Posted: Mon Mar 20, 2023 9:13 pm
by dunbarx
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
Re: Front script only runs when a breakpoint is set
Posted: Mon Mar 20, 2023 9:15 pm
by dunbarx
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
Re: Front script only runs when a breakpoint is set
Posted: Mon Mar 20, 2023 10:45 pm
by bobcole
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
Re: Front script only runs when a breakpoint is set
Posted: Mon Mar 20, 2023 11:15 pm
by dunbarx
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
Re: Front script only runs when a breakpoint is set
Posted: Tue Mar 21, 2023 4:03 am
by Emily-Elizabeth
Commenting out the code didn't work for me, but changing selectedField to selectedObject worked
Re: Front script only runs when a breakpoint is set [SOLVED]
Posted: Tue Mar 21, 2023 1:53 pm
by dunbarx
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:
I get "Field 3"
Craig