The following sections describe JSL syntax rules for the following basic components of the language:
•
|
•
|
•
|
Note: To glue a sequence of commands into a single argument inside a function, separate each sequence with a semicolon. For more information, see Semicolons.
•
|
•
|
•
|
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 in Scripting Tools 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:
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.
JSL allows whitespace characters inside names; spaces, tabs, returns, and blank lines inside or between JSL words are ignored. This is because most JSL words come from the user interface, and most of those commands have spaces in them. For example, the JSL expression for the Fit Model platform is Fit Model() or FitModel().
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).
Numbers can be written as integers, decimal numbers, dates, times, or datetime values. They can also be included in scientific notations with an E preceding the power of ten. For example, these are all numbers:
Note: A single period by itself is considered a missing numeric value (sometimes called NaN for “not a number”).
For more information about dates, times, and date-time values, see Date-Time Functions and Formats in Types of Data. See Currency in Types of Data for details about combining numbers with currency symbols.
A name is simply something to call an item. When you assign the numeric value 3 to a variable in the expression a = 3, a is a name.
Commands and functions have names, too. In the expression Log( 4 ), Log is the name of the logarithmic function.
•
|
Names must start with an alphabetic character or underscore and can continue with the following:
|
•
|
When comparing names, JMP ignores whitespace characters (such as spaces, tabs, and line endings). Upper case and lower case characters are not distinguished. For example, the names Forage and for age are equivalent, despite the differences in white space and case.
|
You can still have a name that is any other sequence of characters. If the name does not follow the rules above, it needs to be quoted and placed inside a special parser directive called Name(). For example, to use a global variable with the name taxable income(2011), you must use Name() every time the variable appears in a script:
Comments are notes in the code that are ignored by the JSL processor (or parser). You include comments to describe sections of the script. Comments are also convenient for removing portions of a script temporarily. For example, you can insert comment symbols around code that might be causing an error and then rerun the script.
Type the comment symbols around code that you want to comment. The following example shows code commented with /* */ in the middle of a line. When the script is run, JMP considers both expressions to be identical.
Comment Symbols describes the comment symbols.
Add //! to the first line of the script, and the script runs automatically when opened in JMP. (In other words, the script editor does not open.)
|