Quasi-bug/strange behavior in error reporting [long]
Jim Witte
jswitte at bloomington.in.us
Wed Apr 23 15:10:01 EDT 2003
Hi,
This probably really should go to the improve-rev list, but I'm not a
professional license holder, so..
I've got a stack that uses a mousedown handler in the card script to
perform a variety of different actions depending on a variable gMode
(yeah, it would probably be cleaner [and a bit faster] if I used an
insert script command.. that's for Apparent Motion v2). Here's the
relevant snippets of code: (In this example, gMode is "delete")
on mousedown
global gMode
if within(graphic "leftFrame", it) then
switch gMode
case "create"
[..]
case "delete"
deleteObj
break [..]
end mousedown
on deleteObj
if not checkMouseControl() then
exit deleteObj
else
[*] get the mouseControl
put id of it into objId [..]
end deleteObj
The checkMouseControl function just returns true if the mouse is over
an appropriate control (a display object in this case).
As written, the script works fine for deleting objects. But if I
comment out the starred line, it breaks - which I expect, because I
don't have the mouseControl in it anymore [side note: the
getMouseControl function does say 'get the mouseControl' but the it
variable must not carry outside of the function's scope].
But the odd thing is the error it gives me. I would expect it to say
there was some kind of error in the deleteObj handler, as that is where
the undefined 'it' is referenced. But instead, it says:
Type: switch: error in statement
Object: Image 1
Line: if within(graphic "leftFrame", it)
Hint: it
which seems to indicate that the error occurs not in the deleteObj
handler, but in the mousedown handler. Is the reason this apparent
error-report inconsistency happens due to the way the engine "inlines"
the handlers together when compiling the script down to a bytecode?
Thanks,
Jim
More information about the use-livecode
mailing list