Thanks to those here who helped, I feel like I didn't add much of my own here. This is basically what I ended up with:
The goal was to have a script that would go through a folder full of text files one at a time, load it, and bring up a Graph Builder window with some settings pre-set, then when Graph Builder is closed, it automatically opens the next one.
The approach I used was to manage it with global variables: "regFlist" is the list of files left to open, and "stopReg" is a flag that when turned on interrupts the process.
There are two scripts: (1) reg_Next.jsl -- checks regFlist, and if it's empty, it asks for a folder to use; otherwise it loads the next file from the regFlist list (if regStop is not set), (2) reg_Stop.jsl -- simply empties regFlist and sets the regStop variable; used to stop the process early.
I'm a total beginner with .jsl, so I'm very open to any feedback/constructive-criticism.
reg_Next.jsl
//!
// use global variables (since hey, what could go wrong? ;) )
Names Default To Here( 0 );
// get path to self
selfPath = get default directory() || "/reg_Next.jsl";
// check to see if user has requested a stop
If( stopReg == 1 ,
stopReg = 0;
regFlist = {};
Stop();
);
// initialize list of files to review if there aren't any in the list
If( Is Empty( regFlist ) | N Items( regFlist ) < 1,
jmpDir = Pick Directory( "Select the jmp directory." );
regFlist = Files In Directory( jmpDir );
);
// open data table and remove it from the regFlist
dt = Open( jmpDir || "/" || regFlist[1] );
regFlist = Remove( regFlist, 1 );
// set up for column switcher
colList = dt << get column names( string );
col1 = colList[1];
col2 = colList[2];
col3 = colList[3];
Remove From( colList, 1, 2 );
// open graph builder
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 );
// set up mechanism to re-run myself when graph builder is closed
If( N Items( regFlist ) == 0,
gb << on close( Close( dt, nosave ) ),
gb << on close(
Close( dt, nosave );
Open( selfPath, Run JSL( 1 ) );
)
);
reg_Stop.jsl
//!
Names Default To Here( 0 );
regFlist = {};
stopReg = 1;