Tip: Keep the log window open to see the output of each script that you run. Select View > Log to open the Log window. See Working with the Log in Scripting Tools.
The following example opens the Big Class.jmp sample data table (making it the current data table), and then specifies row 2 in the weight column. A value of 123 is returned in the log, which is the weight for Louise in row 2.
dt = Open( "$SAMPLE_DATA/Big Class.jmp" );
dt:weight[2];
123
dt = Data Table( "My Table" ); // the open table named My Table
dt = Current Data Table(); // the table in the active window
dt = Data Table( 3 ); // the third open table
Once you have an open data table with a reference, you can send it messages using either the << operator or the Send function. The following example illustrates both methods:
dt = Open( "$SAMPLE_DATA/Big Class.jmp" );
dt << Save();
Send( dt, Save() );
Reference << Message( Arguments );
Current Data Table() << Save();
•
|
You can stack up a series of messages in one statement. Commands are evaluated from left to right, and each returns a reference to the affected object. The following example creates a new data table called My Table, adds two columns to it, and prompts you to save it:
|
dt = New Table( "My Table" );
dt << New Column( "Column 1" ) << New Column( "Column 2" ) << Save( "" );
New Table and Open are commands to create objects that do not exist yet. Once created, you send them messages requesting changes. To close such objects, you must close the objects’ container, because the objects cannot delete themselves.
The following example creates a table and assigns the data table reference to the dt variable. New Column messages are sent to the data table reference. To delete one of those columns, the Delete Columns message is sent to the data table reference, not to the column itself.
dt = New Table( "Airline Data" );
dt << New Column( "Date" );
dt << New Column( "Airline" );
dt << Delete Columns( "Date" );
1.
|
Select Help > Scripting Index.
|
2.
|
Select All Categories from the list.
|
3.
|
Select Data Table in the list.
|
You can also use the Show Properties() command. This is a good approach if you want to print or copy the list of messages. The Show Properties() command lists the messages that you can send to a data table in the Log window. Show Properties() is a command that takes any scriptable object (such as a data table or column) as its argument. To show properties for a data table:
dt = Open( "$SAMPLE_DATA/Big Class.jmp" );
Show Properties( dt );
[Subtable] refers to a set of JMP menu commands. For example, the Tables subtable represents the JMP Tables menu, and the indented messages in this subtable correspond to commands in the Tables menu. Many messages include a short description.
Messages labeled as [Action] all result in some action being taken. Some messages are available for [Scripting Only]. Some messages take a Boolean argument, labeled as [Boolean].
The platforms in the Analyze and Graph menus appear in the properties list because you can send a platform name as a message to a data table. This launches the platform for the data table through the usual launch window. For more information about writing platform-specific scripts, see the Scripting Platforms topic.
dt << Distribution( Y( height ) );
The JMP Scripting Index provides more information about these properties. You can also run and modify sample scripts from the Scripting Index. Select Help > Scripting Index and search for the property in the Objects list.