Random Script Editor problems (AS stops compiling GUI calls)

I’ve encountered a new (to me) problem that (I think) has nothing to do with my code, but is killing my efforts at scripting.

I’ll be working on a script, testing things out, and it will compile and run perfectly. Then I’ll change a line - in the middle of a complex script - and it will no longer compile. Invariably, the error will be "Expected end of line but found ’ " ’ " on my first line of code, which is usally:

tell application "System Events to tell process "Safari" --(occasionally not Safari, but it doesn't make a difference)

The editor highlights the first quotation mark after “process.” Again, that line ran perfectly ten seconds ago, but now it won’t compile. If I keep on trying to compile/run/save, it often replaces every keyword in the script with tags such as <>, but still won’t run.

Usually, the change I’ve made to trigger this is changing one line from “get UI elements of (UI hierarchy)” to “set some_variable to value of (property of a UI element).”

Does anybody know what this is? Do I need to switch editors? Is there a glitch in System Events or AS/AS Editor that causes this to happen if you call GUI statements too much? Would using nested tell statements instead of one compound statement help, or using the com.apple nomenclature instead of the sentence-like code?

Please keep in mind, my software is a little out of date. I’m in the middle of a big project right now and don’t want to upgrade until it’s over because I know a lot of things will have to be rewritten. And I really don’t see how newer software existing elsewhere should have any effect on my one machine.

Thanks in advance for any insight you may have.

Model: Mac Mini
AppleScript: 2.1.2
Browser: Safari 534.59.8
Operating System: Mac OS X (10.6)

It sounds like System Events is crashing. Have Activity Monitor running, and next time it happens, see if System Events is still running.

Quote mark after “Events”?

Yeah, that would help. It was correct in my code, though; I just introduced that typo when I posted. Too bad it’s not that easy.

Thanks for the tip on System Events, Shane. I’m going to give that a crack now.

System Events was to blame. It never stopped running, but my script would work exactly once each time I manually quit System Events. I restarted my machine and it’s been smooth sailing. (Next time I’ll have to remember to try the obvious solutions first…)

Thanks!