Many of the actions that you can do with a JMP Live Connection object are also available on JMP Live Folder objects. The JMP Live Folder object provides the location on JMP Live where the action takes place.
This example shows two ways to obtain a JMP Live Folder object.
// Create a connection to the JMP Live server.
liveconnection = New JMP Live();
// First way: Create a folder, which returns a JMP Live Result object
jmpliveresult = liveconnection << Create Folder( Parent Folder( "/Fab" ), Title( "Create Folder Example" ), If Exists( "use" ) );
// Obtain the JMP Live Folder object from the JMP Live Result object
folder1 = jmpliveresult << As Scriptable;
// Second way: Get an existing folder by path or ID.
jmpliveresult = liveconnection << Get Folder( "/Fab/Tests" );
folder2 = jmpliveresult << As Scriptable;
This example shows how to publish a report using a JMP Live Folder object obtained by creating a new folder.
// Open the Big Class sample data table.
dt = Open( "$SAMPLE_DATA/Big Class.jmp" );
// Run the Distribution table script and call the report "dist".
dist = dt << Run Script( "Distribution" );
// Create a connection to the JMP Live server.
liveconnection = New JMP Live();
// Create a new folder to publish to.
jmpliveresult = liveconnection << Create Folder( Parent Folder( "/Fab" ), Title( "Folder Objects" ), If Exists( "use" ) );
// Obtain the JMP Live Folder object from the JMP Live Result object.
folder = jmpliveresult << As Scriptable;
// Create a content object containing the Distribution report.
content = New JMP Live Content( dist, Title( "My Distribution Report" ) );
// Publish the content to the Folder Objects folder using the folder object.
jmpliveresult = folder << Publish( content );
// Close all data tables in JMP without saving.
Close All( Data Tables, NoSave );
This example uses the Get Folder message to get the JMP Live Folder object for the folder created in the previous example. It then updates the Big Class data table that was published above using that object.
// Create a connection to the JMP Live server.
liveconnection = New JMP Live();
// Get the JMP Live Folder object for the /Fab/Folder Objects folder.
jmpliveresult = liveconnection << Get Folder( "/Fab/Folder Objects" );
// Obtain the JMP Live Folder object from the JMP Live Result object.
folder = jmpliveresult << As Scriptable;
// Open the Big Class sample data table.
dt = Open( "$SAMPLE_DATA/Big Class.jmp" );
// Update the Big Class data table in this folder.
jmpliveresult = folder << Update Data( Data("Big Class"), dt );