@txnelson -- I just spent about 3 hours with the Scripting Index and Scripting Guide trying to make this work, but couldn't figure out how to make the "on close()" function open the next file. Here's what I thought *should* work, but doesn't.
(Reminder, the goal is to step through these files one at a time, bringing up a Graph Builder window and letting me evaluate the file, then when I close the Graph Builder window, it should close the data table and open up the next file and plot it.)
This script is called "jmp_reg_4.jsl" and is on my Desktop:
Names Default To Here( 0 ); // <-- trying to use globals so the file list will be maintained between invocations
/*
All of what you suggest is doable in JMP.
You can use "Files in Directory()" to get the file list, and then loop through them.
You can attach an "On Close()" function to the Graph Builder object, which will close the current data table, and then go get the next file from your list of files from the "Files in Directory()" list.
Examples and description are in the Scripting Index
Help==>Scripting Index
*/
If( Not( As Global( "flist" ) ),
jmpDir = Pick Directory( "Select the jmp directory." );
flist = Files In Directory( jmpDir );
);
dt = Open( jmpDir || "/" || flist[1] );
Remove( flist, 1 );
colList = dt << get column names( string );
col1 = colList[1];
col2 = colList[2];
col3 = colList[3];
Remove From( colList, 1, 2 );
gb = dt << Graph Builder(
size( 800, 600 ),
Variables( X( As Column( col2 ) ), Y( As Column( col3 ) ), Overlay( As Column( col1 ) ) ),
Elements( Points( X, Y, Legend( 10 ) ), Line( X, Y, Legend( 11 ) ) )
);
cs = gb << Column Switcher( col3, colList );
gb << on close(
Close( dt, nosave );
run script( "/Users/bh/Desktop/jmp_reg_4.jsl" );
);
I thought I was creating a global list of files to examine, and then at every invocation, if I still have elements in the "flist" (file-list) variable, then we simply grab the next one and load it and plot it. But it's not working as I expect: when I close the graph builder window, it correctly closes the data table, but then does nothing else.