Use the Open() function to open a data table.
The path to the data table can be a quoted literal path (absolute or relative) or an unquoted expression that yields a pathname. Relative paths are interpreted relative to the location of the .jsl file (for a saved script). For unsaved scripts, the path is relative to your primary partition (Windows) or your <username>/Documents folder (Macintosh).
JMP provides shortcuts (path variables) to directories or files. Instead of entering the entire path to the directory or file, you include a path variable in the Open() expression. For example, JMP sample scripts typically use the $SAMPLE_DATA path variable to open files in the Samples/Data folder. For details about path variables, see “Path Variables” on page 129 in the “Types of Data” chapter.
In a script that depends on an opened data table, you can test to see whether the table is open using Is Empty() or Is Scriptable(). In the following example, the script performs a Bivariate analysis on Big Class.jmp and then closes the data table. Before proceeding to the Oneway analysis later in the script, Is Scriptable() tests for the open data table. If 1 (true) is returned, the table opens, and the script continues.
obj = dt << Bivariate( Y( :height ), X( :age ), Fit Line );
Close( dt );
You might want to see if the data table is open and then close it to discard any changes before running another script on the data table. To test for and close Big Class.jmp, run the following script:
You can use an If() expression to prompt a user to open a data table, if no open data table is found. And if they do not select a table, the script should end. The following script shows an example:
dt = Current Data Table();
If( Is Empty( dt ),
The user is prompted to open a data table. If the user clicks Cancel instead of opening a data table, an error appears in the log.
To open a data table and show only a specific set of columns, identify those columns in the Open() expression. This is particularly helpful with a large data table in which only a few columns are necessary.