CommentsTo explain what a script does, you add comments. A comment is text that remains in a script after compilation but is ignored by AppleScript when the script is executed. There are two kinds of comments:
You can nest comments, that is, comments can contain other comments.
- A block comment begins with the characters
(*and ends with the characters
*). Block comments must be placed between other statements. They cannot be embedded in simple statements.
- An end-of-line comment begins with the characters
--and ends with the end of the line.
Here are some sample comments:
--end-of-line comments extend to the end of the line; (* Use block comments for comments that occupy more than one line *) copy result to theCount--stores the result in theCount (* The following subroutine, findString, searches for a string in a list of Scriptable Text Editor files *) (* Here are examples of --nested comments (* another comment within a comment *) *)The following block comment causes an error because it is embedded in
--the following block comment is illegal tell application "Scriptable Text Editor" get (* word 1 of *) paragraph 1 of front document end tellBecause comments are not executed, you can prevent parts of scripts from being executed by putting them within comments. You can use this trick, known as "commenting out," to isolate problems when debugging scripts or temporarily block execution of any parts of script that aren't yet finished. Here's an example of "commenting out" an unfinished handler:
(* on finish() --under construction end *)If you later remove
*), the handler is once again available.