|
Comment
|
|
Commenting and uncommenting code is a common need when developing AppleScript code, and Script Debugger provides an editing shortcut for doing this.
To comment out a stretch of code, select the code and choose Edit > Comment. Script Debugger will extend the selection to consist of complete lines, and will then insert a single-line comment character at the start of each of those lines.
To turn comments into code, select some code and choose Edit > Uncomment. Script Debugger will extend the selection to consist of complete lines, and will then remove a single-line comment character from the start of each of those lines, if there is one. (If there isn’t one, that’s fine. The line is left unaltered.)
(You can also add Comment and Uncomment buttons to the script window’s toolbar.)
Why does Script Debugger use single-line comments rather than surrounding the selected text with block comment delimiters, (* like this *)? One reason is that block comments are fragile. An unbalanced double-quote within block comment delimiters will keep your script from compiling. Single-line comments are simpler. In fact, with Script Debugger, multiple single-line comments are easier to deal with than block comments. To insert block comment delimiters, choose Clippings > Block Comment.
An Editor preference governs what is actually inserted at the start of each line when you choose Edit > Comment. This permits you to use, for example, either “--” (the traditional comment character) or “#” (the new comment character introduced in Mac OS X 10.5), and to set the number of spaces that should follow the comment character.