cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Browse apps to extend the software in the new JMP Marketplace
Choose Language Hide Translation Bar
lpatton
Level I

How can I force my script to execute sequentially?

My current JSL script works perfectly when I step through it however, when executed it can throw up some errors.  I can handle this somewhat by putting the wait() function in but it doesn't always work.  Is there a simple function I can call out at the top of my script to make it execute sequentially?

2 ACCEPTED SOLUTIONS

Accepted Solutions
txnelson
Super User

Re: How can I force my script to execute sequentially?

It is a best practice to pass to the data table a message of which platform to run, rather than having to keep track of which table is the current active table.  So rather than:

dt = Data Table( "data table xxx" ) ;

dt << Clear Select;

dt<<Bring Window To Front;

Bivariate(X(.......

dt = Data Table( "data table xxx" ) ;

dt << Bivariate(X(.........

insures the Bivariate Pllatform will run on the data table referenced by "dt"

Jim

View solution in original post

txnelson
Super User

Re: How can I force my script to execute sequentially?

When I code a fairly complex script, I typically use the following structure for my code:

Main = Expr(
     returna = A(passing variables);
     returnb = B(passing variables);
);
A = Function({Passed variables},
    processing code
);
B = Function({Passed variables},
     processing code
);
// Enter the script by executing the Main section
Main;

Concering your questuions about Recode and Col Info items, the answers are, No and Yes.  There is no direct funtion to run the Recode element from interactive JMP.  This is because it is easier to replicate the functionality in open JSL.

Names Default to Here( 1 );
dt = Open( "$SAMPLE_DATA\Big Class.jmp" );
dt:Sex[ dt << Get Rows Where( :Sex == "F" )] = "Female";
dt:Sex[ dt << Get Rows Where( :Sex == "M" )] = "Male";

// or

For Each Row(
     If( :Sex == "F", :Sex = "Female",
          :Sex = "Male"
     );

As for items in the Col Info dialog box, Formating, Column Properties such as Value Ordering, Spec Limits, etc. are all available in JSL to be changed to what they need to be changed to.

 

All of this is covered in the Scripting Guide

     Help==>Books==>Scripting Guide

and/or in the Scripting Index

     Help==>Scripting Index

Jim

View solution in original post

9 REPLIES 9
txnelson
Super User

Re: How can I force my script to execute sequentially?

The method that I use is to break the script into functional components, and then to have the control section of the script step through the script, and calling in the components when I need them.  I typically place the code into EXPR(() sections.  The code placed in EXPR() will not be execututed until called by the control section.

Jim
mikedriscoll
Level VI

Re: How can I force my script to execute sequentially?


@txnelson wrote:

The method that I use is to break the script into functional components, and then to have the control section of the script step through the script, and calling in the components when I need them.  I typically place the code into EXPR(() sections.  The code placed in EXPR() will not be execututed until called by the control section.


When you say you call the components when you need them, do you mean that you call the expressions within the control section and run it straight through, or do you have to call them manually and individually so that the previous function finishes? If the former, how is the control section structured so that it really does wait?

 

Is there a way to call native functions like recode and column info (to change value ordering) as modal windows / functions?

 

Thanks,
Mike

txnelson
Super User

Re: How can I force my script to execute sequentially?

When I code a fairly complex script, I typically use the following structure for my code:

Main = Expr(
     returna = A(passing variables);
     returnb = B(passing variables);
);
A = Function({Passed variables},
    processing code
);
B = Function({Passed variables},
     processing code
);
// Enter the script by executing the Main section
Main;

Concering your questuions about Recode and Col Info items, the answers are, No and Yes.  There is no direct funtion to run the Recode element from interactive JMP.  This is because it is easier to replicate the functionality in open JSL.

Names Default to Here( 1 );
dt = Open( "$SAMPLE_DATA\Big Class.jmp" );
dt:Sex[ dt << Get Rows Where( :Sex == "F" )] = "Female";
dt:Sex[ dt << Get Rows Where( :Sex == "M" )] = "Male";

// or

For Each Row(
     If( :Sex == "F", :Sex = "Female",
          :Sex = "Male"
     );

As for items in the Col Info dialog box, Formating, Column Properties such as Value Ordering, Spec Limits, etc. are all available in JSL to be changed to what they need to be changed to.

 

All of this is covered in the Scripting Guide

     Help==>Books==>Scripting Guide

and/or in the Scripting Index

     Help==>Scripting Index

Jim
mikedriscoll
Level VI

Re: How can I force my script to execute sequentially?

Thanks for the reply. I tried setting up as functions and it still didn't wait for user input.  For the recode and value ordering questions, I'm familar with them, but I should have put more emphasis on running them (or any native functions really) as modal which I was hoping might execute in such a way to complete the function before stepping to the next line of code.

 

I see what you're saying regarding using jsl to directly recode this, but I was hoping for a mix of jsl + native UI to run through a bunch of common tasks that are always the same (hard coded scripting is fine) with other tasks whose inputs / outputs change and therefore lend themselves to the native UI, such as value ordering and recode. I found Craige's post from back in March where he posted something that can do this, but it is a little restrictive because of column name -> function window naming. In my case I'll have the column names in strings up top, so its fine for me. Here it is modified for 2 levels of interactivity. Tested on JMP13 standard.

 

dt = Open( "$sample_data/big class.jmp" );
dt << Go To( :sex ) << Recode;	// First interactivity, as a test, change "F" to "Female"

Window( "Recode" ) << onclose(
	dt << Go To( :sex );
	main menu("column info");	// second interactivity, as a test, change value ordering properties.
	
	Window( "sex" ) << onclose(	
		dt:Sex[ dt << Get Rows Where( :Sex == "M" )] = "Male";
	);
);
mikedriscoll
Level VI

Re: How can I force my script to execute sequentially?

Well apparently it isn't as rosy as I hoped. Some code doesn't execute properly in that onclose() command.  A 'dt << sort(...)' did not properly in the inner onclose() but it worked ok if I commented the inner onclose() out.

pmroz
Super User

Re: How can I force my script to execute sequentially?

I put wait(0); statements between sections of code I want to execute sequentially.

Jeff_Perkinson
Community Manager Community Manager

Re: How can I force my script to execute sequentially?

I'm sorry to hear that you're having trouble here.

Our goal is that you should never need a Wait() in order to make your script run. We do know that there are times when the various elements of the UI (windows, platforms, etc.) need a moment to get themselves fully instantiated before they can respond appropriately to the rest of your JSL. However, we want to address those situations internally so you don't have to worry about it in your JSL.

So, when you run across situations that are resolved by adding a Wait() into your code, please submit them to Tech Support, so we can track them and resolve them.

Thanks!

-Jeff

-Jeff
guy_yosef
Level III

Re: How can I force my script to execute sequentially?

i had several errors when running scripts automaticly, but when i tested them manually it was ok.

for those type of errors, it usually happen to me when i  try to do a plot base on wrong table

now i add  those lines before doing plots/charts in scripts

dt = Data Table( "data table xxx" ) ;

dt << Clear Select;

dt<<Bring Window To Front;

txnelson
Super User

Re: How can I force my script to execute sequentially?

It is a best practice to pass to the data table a message of which platform to run, rather than having to keep track of which table is the current active table.  So rather than:

dt = Data Table( "data table xxx" ) ;

dt << Clear Select;

dt<<Bring Window To Front;

Bivariate(X(.......

dt = Data Table( "data table xxx" ) ;

dt << Bivariate(X(.........

insures the Bivariate Pllatform will run on the data table referenced by "dt"

Jim