Previous Book Contents Book Index Next

Inside Macintosh: AppleScript Language Guide / Part 1 - Introducing AppleScript
Chapter 2 - Overview of AppleScript / Other Features and Language Elements


Comments

To 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.

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
a statement.

--the following block comment is illegal
tell application "Scriptable Text Editor"
   get (* word 1 of *) paragraph 1 of front document
end tell
Because 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 (* and *), the handler is once again available.


Previous Book Contents Book Index Next

© Apple Computer, Inc.
13 JUL 1996