FANDOM


Comments are notes that the programmer places in the script to remind him/her of something or to assist someone who is reading the script or program. The compiler sees the comment indicators and does not compile the comment. They are considered essential in good programming practice. They can be sort of a diary not only for yourself, but anyone who may need to build on your code.

Single Line CommentsEdit

Set off by double hyphens at the beginning of the comment. This type of comment can only be on one line. You will receive a compiler error if the comment is on multiple lines. This is because the compiler compiles the parts of the comment that are not on the first line of the comment. Your comment most likely does not contain actual code.

--Your single line comment here

Alternative Single Line CommentsEdit

Starting in AppleScript 2.0, support for comments using "#" was added.

#Here is an alternate comment, as long as you have updated AppleScript to 2.0 or later

This has various uses such as turning a script into a Unix executable. This can be done by adding:

#!/usr/bin/osascript

to the beginning of a script

Block CommentsEdit

Set off by (* and ended with *). This type of comment creates a "block" of text that the compiler ignores i.e. a comment that can extend for a few lines.

(* Your single line comment here. *)

or

(* First line...

Second line...

and so on... *)

Nested CommentsEdit

Like with other commands in AppleScript—If-then-else, for example—you can nest comments within each other

(*  Here are some

    --nested comments

    (* another comment within a comment *)

*)

Ad blocker interference detected!


Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers

Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.