Long-deleted code still somehow present?

I’m building my first AppleScript studio application. It was going smoothly until I hit this seemingly insurmountable problem:

I created a bit of code that placed the path name of a file from an “open” panel into a text field. The open panel was invoked by pressing a button beside this text field.

I deleted the code for the button that governed everything except merely opening the panel. I compiled and ran the program, and selecting a file still caused it to enter the path into the adjacent text field. Now, this was rather odd since there was no longer any reference to the text field in the script. The script should not have been touching that field at all.

Thinking that perhaps I had somehow compiled an older version of the script, not the version I was currently working on, I deleted the part of the script that invoked the “open” panel when clicking the button, and recompiled to see if this change would take effect. The button ceased to function, as it should.

Next, I deleted ALL of the script, saved it, and added back in the bit that invoked the open panel:

on clicked theObject
display open panel attached to window of theObject
end clicked

At this point, this was the entire contents of the program.

Impossibly, the button still had complete functionality after compiling. I quit Xcode, I quit Interface Builder, I shut everything out that could possibly be creating a problem, and opened the project file once more.
Only one Applescript file in the project, check.
Only these three lines of code in said Applescript, check.
Only one button with clicking behavior defined, pointing to afformentioned script, check.

Compile.
Run.
Same problem.

What is going on?

aaaHAAAAA!!! I figured out what the problem is. Or rather, I found the location of the problem, but it still makes no sense.

I ticked and then unticked the “panel ended” event handler. This seems to have caused it to dump whatever old code it was apparently caching. This is odd, since I had disabled the event handler long ago, even going so far as to manually wipe out the code associated with it, yet it persisted.

I take it that this is a bug? I’m working with Xcode 1.1, so perhaps this problem has been fixed in Tiger.

This happens (at least to me) every now and then. That’s why there is “Clean” and “Clean All Targets” in the Build menu. Gives a program a nice high colonic - the Xcode kind!

Xcode2 has fewer of these code caching problems, but they aren’t completely gone. From my own observations, they tend to happen more with removing (or commenting out) than adding new code. And I’ve never seen them for anything except Applescript Studio programs too.

I posted a topic a while ago under “(Rant) something” where changing from Deployment to Development solved a problem. I’ve seen my builds lose their icons, their Finder drag-n-drop ability, a whole host of issues - solved with the colonic action of… “Clean”.

More Purging = Happier A.S.S. (hey, HEY!! That’s AppleScript Studio)

Haha, excellent! Clean All Targets will probably preserve many clumps of my hair as I work more with Applescript. Thanks!