You can use shortcuts to comment or uncomment a stretch of code.
To comment out a stretch of code:
Select the code and choose Edit > Comment. Or choose Comment from the contextual menu.
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 uncomment a stretch of comments:
Select some code and choose Edit > Uncomment. Or choose Uncomment from the contextual menu.
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, use the Block Comment clipping.
A single-line comment character can be either “--
” (the traditional comment character) or “#
” (the new comment character introduced in Mac OS X 10.5). To determine which is inserted by the Comment command, and to set the number of spaces that should follow the comment character, use the Editor preference, “Edit > Comment Inserts.”