An operator is one- or two-character symbol (such as + or =) for features such as common arithmetic actions, scoping names, regular expressions, concatenating, and subscripting.
A function is a command that might contain additional information for the function to use.
2 + 3; // returns 5
Add( 2, 3 ); // returns 5
Although all JSL operators have function equivalents, not all functions have operator equivalents. For example, Sqrt(a) can be represented only by the Sqrt() function.
Note: In previous versions of JMP and its documentation, the terms operators and functions were used interchangeably. Now each term has a specific meaning.
An object is a dynamic entity in JMP, such as a data table, a data column, a platform results window, a graph, and so on. Most objects can receive messages that instruct the object to perform some action on itself.
A message is a JSL expression that is directed to an object. That object knows how to evaluate the message. In the following example, dt is the data table object. << indicates that a message follows. In the following example, the message tells JMP to create a summary table with the specified variables.
dt << Summary( Group( :age ), Mean( :height ) )
In this expression, dt is the name of a variable that contains a reference to a data table. You could use any name for this variable. This book commonly uses dt to represent data table references. Here are some of the more common names used in this book to represent references to certain objects:
dt |
|
col |
|
colname |
|
obj |
|
db |
These variables are not pre-assigned references. Each one must be assigned prior to its use. In the following example, the global variable named A is assigned the value “Hello, World”. When the Show( A ) command is processed, the result is the value of A.
A = "Hello, World";
Show( A );
A = "Hello, World";
An argument is additional information that you can provide to a function or message. For example, in Root(25), 25 is an argument to the Root() function. Root() acts on the argument that you provide and returns the result: 5.
Programming and scripting books commonly talk about parameters as well. A parameter is a description of the argument that a function accepts. For example, the general specification for Root() might be Root( number ), where number is the parameter.
Parameter and argument express two perspectives of the same concept: information that a function needs.
For simplicity in this book, we use the word argument in both cases.
A named argument is an optional argument that you select from a predetermined set and explicitly define. For example, title("My Line Graph") in the Graph Box() function is a named argument because the title is explicitly defined as such.
Graph Box( title( "My Line Graph" ),
Frame Size( 300, 500 ),
Marker( Marker State( 3 ), [11 44 77], [75 25 50] );
Pen Color( "Blue" );
Line( [10 30 70], [88 22 44] ));
Note that the Frame Size() arguments 300 and 500 are not named. The position of these arguments implies meaning; the first argument is always the width, the second argument is always the height.
Root( x, <n> )
Optional arguments often have a default value. For example, for Root(), the default value of n is 2:
Root( 25 ) |
5 |
|
Root( 25, 2 ) |
5 |
|
Root( 25, 3 ) |
2.92401773821287 |
An expression is a section of JSL code that accomplishes a task. JSL expressions hold data, manipulate data, and send commands to objects. For example, the following expression opens the Big Class.jmp sample data table and creates a Bivariate graph:
dt = Open( "$SAMPLE_DATA/Big Class.jmp" );
dt << Bivariate( Y( :weight ), X( :height ) );
A single vertical bar (|) represents a logical OR. For brevity, | represents the word or when referring to alternative values.
For example, a pathname can be either absolute or relative. When you see an argument such as absolute|relative, this means that you enter either one of the following two options:
•
|
absolute indicates an absolute pathname.
|
•
|
relative indicates a relative pathname.
|
// Expression 1
sum = 0;
For( i = 1, i <= 10, i++,
sum += i;
Show( i, sum );
);
// Expression 2
Sum = 0;
For( i = 1, i <= 10, i++,
Sum += i;
Show( i, Sum );
);
You can format your script in any way that you like. However, the script editor can also format your script for you. This book uses the script editor’s default formatting for capitalization, spaces, returns, tabs, and so on. See Using the Script Editor in Scripting Tools for details about using the script editor.
Note: The only white space exception is two-character operators (such as <= or ++). The operators cannot be separated by a space.