Making Script Files Readable; Commenting The Script; Continuing Long Lines In Applescript And Vbscript; Continuing Long Lines In Javascript - Adobe 27510753 - InDesign CS2 - PC Manual

Scripting guide
Hide thumbs Also See for 27510753 - InDesign CS2 - PC:
Table of Contents

Advertisement

Adobe InDesign CS2 Scripting Guide
Making script files readable
Comments within scripts and formatting of scripts make them easier to understand and to maintain.

Commenting the script

Comments let you add descriptive text to a script. The scripting system ignores comments as the script
executes; this prevents comments from producing errors when you run your script. Comments are useful
when you want to document the operation of a script (for yourself or for someone else).
To include a comment in an AppleScript, type "--" to the left of your comment or surround the comment with
"(*" and "*)". In VBScript, type "Rem" (for "remark") or "'" (a single straight quote) to the left of the comment.
Type the comment marker at the beginning of a line to make the entire line a comment. In JavaScript, type "//"
to the left of the comment, or surround the comment with "/*" and "*/". For example:
AppleScript
VBScript
JavaScript

Continuing long lines in AppleScript and VBScript

In both AppleScript and VBScript, a carriage return at the end of a line signals the end of the statement. Script
lines, however, can be quite long. How can you make the script more readable without breaking the long
lines?
Both AppleScript and VBScript define special continuation characters—characters that break a line but that
direct the script to read the broken line as a legitimate instruction. In AppleScript, type Option+Return
(displays as ¬) to enter a continuation character. In VBScript, type an underscore (_) followed by a carriage
return at the end of the line to continue the line.
In both languages, you cannot put the continuation character inside a string.

Continuing long lines in JavaScript

In JavaScript, a semicolon (;) indicates the end of a statement. Statements can contain carriage returns, so
there's no need for a continuation character. At the same time, InDesign's ExtendScript interpreter does not
require semicolons at the ends of statements, and interprets each line as a complete statement if it is possible
to do so. For example:
return
true;
is not interpreted as:
return true;
In general, therefore, it's best to end each line with a semicolon, and to insert returns only at the ends of
statements.
--this is a comment
(* and so is this *)
Rem this is a comment
' and so is this
// this is a comment
/* and so is this */
Scripting Basics
7

Hide quick links:

Advertisement

Table of Contents
loading

This manual is also suitable for:

Indesign cs2

Table of Contents