The following sections describe JSL syntax rules for the following basic components of the language.
注意:To glue a sequence of commands into a single argument inside a function, separate each sequence with a semicolon. For more information, see Semicolons.
•
|
y = 10;
If(
Y < 20, X = Y,
X = 20
•
|
•
|
Parentheses also mark the end of a function name, even when arguments are not needed. For example, the Pi function has no arguments. However, the parentheses are required so that JMP can identify Pi as a function.
|
Pi();
The script editor can match fences (parentheses, brackets, and braces). Press CTRL-] (COMMAND-b on Macintosh) with your cursor in any part of a script. The editor searches for fences, highlighting the text between the first set of opening and closing fences that it finds. Repeat this process to highlight the next-higher fence. See “Match Parentheses, Brackets, and Braces” on page 56 in the “Scripting Tools” chapter for an example.
Expressions separated by a semicolon are evaluated in succession, returning the result of the last expression. In the following code, 0 is assigned to the variable i and then 2 is assigned the variable j.
You can also use semicolons to join arguments that are separated by commas as shown in the following If() expression.
The semicolon in other languages is used as an expression terminator character. In JSL, the semicolon is a signal to continue because more commands might follow. For details about separating expressions with semicolons, see Alternatives for Gluing Expressions Together.
The semicolon is equivalent to the Glue() function. See Operators for more information about semicolons and Glue().
Double quotes enclose text strings. Anything inside double quotes is taken literally, including spaces and upper- or lower-case; nothing is evaluated. If you have "Pi() ^ 2" (inside double quotes), it is just a sequence of characters, not a value close to ten.
To have double quotes inside a quoted string, precede each quotation mark with the escape sequence \! (backslash-bang). For example, run the following script and look at the title of the window:
New Window( "\!"Hello\!" is a quoted string.",
inserts line breaking characters appropriate for the host environment1
|
|
Sometimes, long passages require a lot of escaped characters. In these cases, use the notation \[...]\ and everything between the brackets does not need or support escape sequences. Here is an example where \[...]\ is used inside a double-quoted string.
jslPhrase = "The JSL to do this is :\[
Spaces inside an operator or between digits in a single number are not allowed. In these cases, the script generates errors. For example, you cannot put spaces between the two plus signs in i++ (i+ +) or in numbers (4 3 is not the same as 43).