image

Hey, Script Debugger Changed My Formatting!

image

Sometimes it happens that the appearance of your script is changed in ways you never intended. For example, you carefully use the line continuation character to break up a long line of code, like this:

set r to display dialog "What is your favorite color?" ¬
  default answer "Blue. No, red!" ¬
  buttons "Aaaaaaaagh!" ¬
  default button "Aaaaaaaagh!" ¬
  with title "A Crucial Test"

But suddenly it appears broken up all incorrectly, like this:

set r to display dialog ¬
    "What is your favorite color?" default answer ¬
    "Blue. No, red!" buttons ¬
    "Aaaaaaaagh!" default button ¬
    "Aaaaaaaagh!" with title "A Crucial Test"

Why is Script Debugger doing this to you? We’re sorry this is happening, but Script Debugger has nothing to do with it. It’s a “feature” of AppleScript. It has to do with the fact that a script is compiled into bytecode and then displayed to you in decompiled form. There are some annoying behaviors deep within that round-trip process, and this is one of them. There’s nothing Script Debugger can do to prevent it.

A related behavior is that although AppleScript will let you use a term’s synonym, it will also sometimes replace the synonym in the decompiled script. So, for example, close document 2 saving false is legal, but it is changed to close document 2 without saving (and you are probably familiar with the expansion of app to application, ref to a reference to, and so forth).



image
Why Do Applications Open Spontaneously? How Do I Script Script Debugger?
image