Subscribe Bookmark RSS Feed

JSL recursion prevented

msharp

Super User

Joined:

Jul 28, 2015

From the switch to JMP 13 from JMP 12 I keep running across errors due to "JSL recursion prevented".  Mostly this is a good thing as I've had to fix bad practices in my code base, however often it just limits functionality.  Where I'm seeing it currently is in one of my reports I have a "filter" button, that reruns the display filtering out user specified data.  If that button is pushed too many times by the user they get a "JSL recursion prevented" error killing the script. Is there a way to turn this off?  Sometimes I want recursion, it can be a good thing!  This error has been the bane of my existence since JMP 13.

3 REPLIES
msharp

Super User

Joined:

Jul 28, 2015

So I figured out a solution to my issue, I have no idea why it works.  The first thing I did was move the << Get Selected commands into the run funciton and just pass the combo box, and this fixed 99% of my recursion issues.  I don't understand this part, so if anyone from JMP could enlighten me why this would be I would appreciate it.

 

The second thing I had to do was disable the button while the code was running, b/c if a user double clicked fast enough it would cause a recursion error due to the first button click still trying to run.  This part makes sense to me, but doesn't seem like I should have to code around it.  A user clicking a button shouldn't cause a recursion error.  At most, it should simply just add the new click onto the processing stack; and at least it should just ignore the extra click.  It should never actually try to run it again to cause the recursion issue.

 

 

//Old Script
BBRun = button box("Run Filter",
	layerId = layer_cb << Get Selected;
	classId = class_cb << Get Selected;
	runFunction(dt, layerid, classid);
)

//New Script
BBRun = button box("Run Filter",
	BBRun << Enable(0);
	runFunction(dt, layer_combobox, class_combobox);
	BBRun << Enable(1);
)

//Run Function for reference
runFunction = function({dt, layer_cb, class_cb}, {Default Local},
//Grab data
layerId = layer_cb << Get Selected;
classId = class_cb << Get Selected;

//Create namespace to pass variables
If( !Namespace Exists( "filterCode_script" ),
FC = New Namespace( "filterCode_script" ),
FC = Namespace( "filterCode_script" )
);
//get unique defects
FC:defects = dt:defects[dt << Get Rows Where(:LAYER_ID == layerId & :CLASS_ID == classId)];

//Create display window for subset
include("$ADDIN_HOME(myaddin)\Includes\filterWindow.include.jsl", <<New Context, <<Names Default to Here);
FC << Delete;

);
Craige_Hales

Staff

Joined:

Mar 21, 2013

Are you using wait() statements? Maybe you can switch to using dt<<runFormulas and displaybox<<updateWindow which avoid the wait statement issues (how long to wait, button events run).

I used this to try to understand what's happening:

 

New Window( "x",
	t = Text Box( "" ),
	Button Box( "updatewindow",
		print("pressed updatewindow");
		start = Tick Seconds();
		For( i = 1, i < 1e3, i++,
			t << settext( Char( i ) );
			t << updatewindow;
		);
		stop = Tick Seconds();
		t << settext( Char( stop - start, 4, 1 ) );
	),
	Button Box( "wait",
		print("pressed wait");
		start = Tick Seconds();
		For( i = 1, i < 1e3, i++,
			t << settext( Char( i ) );
			Wait( 0 );
		);
		stop = Tick Seconds();
		t << settext( Char( stop - start, 4, 1 ) );
	)
);

change the 1e3 to 1e4 if it runs too fast. The "wait" button allows events to process, including either button to be pressed during the script that "wait" is running. The "updatewindow" button only updates the text box and queues additional clicks until the script finishes.

 

Sometimes wait() is unavoidable; when a platform is launched it will not appear on the screen without a wait(). And JMP's background processing also requires a wait() in a script that is looping (sockets, runprogram, database connections, probably others).

The log message does not look like it should hurt anything; I think it is just warning that a second press of the same button before the button script finishes has been ignored.

Craige
msharp

Super User

Joined:

Jul 28, 2015

Thanks Craig, this was very beneficial.  Yes, I am using wait(0) in my script.  I tried switching it out since I saw a large speed boost with update window, but I believe wait(0) is what I will need to use.  This does answer several of my questions and helps me understand what's going on under the hood a little better.  Thanks!