Choose Language Hide Translation Bar
Highlighted
ckerr
Level III

'nested' script execution issue in JMP15

I am running Windows 7, JMP versions 12, 13, 14 and 15.

I am observing problems in JMP15 with 'wrapper' scripts that contain code to sequentially execute other subordinate/nested scripts.

These scripts were written in pre-15 versions and run properly there.  Some - but not all - of these wrapper/nested script collections fail to run correctly in JMP15.

Each of the separate scripts runs correctly in JMP15 if run singly. 

 

My apologies in advance for not being able to submit a complete set of scripts, but I have supplied generic examples of both types.

 

The 'wrapper' script is of the generic form:

//start wrapper.jsl
names default to here(1);
close all (data tables, no save);
clear log();

subordinate_scripts = {"subord1.jsl","subord2.jsl","subord3.jsl","subord4.jsl"};

for( i = 1, i <= n items(subordinate_scripts), i++,
	beacon = 1; //variable gets set to 0 by last line of subordinate script
	open(subordinate_scripts[i]);
	if(beacon !=0,
		write("\!NScript "||subordinate_scripts[i]||" did not successfully execute to completion.";
		throw();
	);
);
//end wrapper.jsl

The nested scripts subord1.jsl, etc. are of the generic form

//! //start subord script so it will auto-execute when opened by wrapper.jsl
/* bunch of stuff, e.g.
	aggregating multiple files
	database queries
	data processing / reshaping
	saving large files
	building extensive reports in the journal
	executing other scripts
*/
beacon = 0;
//end subord script

The subordinate script signals complete execution to the wrapper script by changing the value of beacon to 0 as its last instruction.

If beacon == 0, the wrapper script starts the next cycle of the FOR loop and opens the next subordinate script.

 

What I have seen in JMP15 suggests the following order of events:

  • wrapper script starts
  • beacon set to 1
  • first subordinate script starts
  • wrapper script does NOT wait for subordinate script to finish. 
  • wrapper script execution continues to the IF statement.
  • beacon ==1
  • message is printed saying subordinate script failed (Note that the subordinate script is already running at this point)
  • wrapper script stops
  • subordinate script finishes executing successfully.
  • Next subordinate script is not opened because the wrapper stopped

The usual order of events in pre-JMP15 versions is

  • wrapper starts
  • wrapper sets beacon = 1
  • wrapper opens subordinate script, then idles until the subordinate script finishes
  • subordinate script runs, setting beacon = 0 as last instruction
  • wrapper script checks beacon value.
  • since beacon ==0, the next cycle of the FOR loop is executed.
  • all subordinate scripts are sequentially run.

Does anyone have a suggestion for making this scripting idiom work in JMP15?

Thank you in advance.

 

 

 

2 ACCEPTED SOLUTIONS

Accepted Solutions
Highlighted
vince_faller
Super User

Re: 'nested' script execution issue in JMP15

sounds like you should be using 

include() 

instead of 

open()

Vince Faller - Predictum

View solution in original post

Highlighted
ckerr
Level III

Re: 'nested' script execution issue in JMP15

The very thing!
I swapped include() in for open() and it all started working again.
Thank you for bailing me out.

View solution in original post

5 REPLIES 5
Highlighted
vince_faller
Super User

Re: 'nested' script execution issue in JMP15

sounds like you should be using 

include() 

instead of 

open()

Vince Faller - Predictum

View solution in original post

Highlighted
ckerr
Level III

Re: 'nested' script execution issue in JMP15

The very thing!
I swapped include() in for open() and it all started working again.
Thank you for bailing me out.

View solution in original post

Highlighted
ckerr
Level III

Re: 'nested' script execution issue in JMP15

Any ideas why open() and include() are no longer interchangeable?

 

Highlighted
Craige_Hales
Staff (Retired)

Re: 'nested' script execution issue in JMP15

I'll guess: the beacon variable is sometimes local to the sub-script. Maybe NamesDefaultToHere is involved. A quick test suggests that JMP 15 does honor NamesDefaultToHere which makes beacon local to the sub-script when JMP 14 did not. @EvanMcCorkle @audrey_shull 

 

file=savetextfile("$temp/xxx.jsl","//!
namesdefaulttohere(1);
xyzzy=42;show(xyzzy)");
open(file);
show(xyzzy);

Like Vince, I'd use include() rather than open() for this because it doesn't need the //! .

You could also use ::beacon to make it a global variable.

Or remove the NamesDefaultToHere from the sub-scripts that have it.

 

Craige
Highlighted
ckerr
Level III

Re: 'nested' script execution issue in JMP15

Thank you for the response, Craige.  More good advice that I will implement.  Much appreciated.

 

 

Article Labels

    There are no labels assigned to this post.