cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Check out the JMP® Marketplace featured Capability Explorer add-in
Choose Language Hide Translation Bar
haleyhoewt
Level I

Script skipping order of evaluation

Hi. I'm hoping that this is just a fluke on my part. 

 

I have a script that first creates a "duration" column & evaluates. 

Next, i have the script find blanks and fill with previous non blank value (for deadbanding). it does this by generating a pop-up window for one to select which columns need this applied (granted, if i could just assume all of them need it, that *could* be one option of circumventing this issue)

However, the script doesn't "wait" for me to select which columns i want to fill down before moving to next lines. 

 

How do i get around this??

 

Names Default to Here(1);
dt=Current Data Table();
column(dt, "Time")<<Data Type("Numeric", Informat("m/d/y h:m:s"), Format("h:m:s"));
dt1=Current Data Table();
dt1<<New Column("Duration", Units("seconds"), Formula(:Time-Col Minimum(:Time)));
Column("Duration")<<data type(Numeric)<< Modeling Type(Continuous)<< Format("fixed dec", 20, 0);


_dt = Current Data Table();

colnames = _dt << Get Column Names( String );

fillcolumns = Expr(
	selectedcols = _lb << Get Selected;
	nc = N Items( selectedcols );

	nr = N Rows( _dt );

	For( ii = 2, ii <= nr, ii++,
		For( jj = 1, jj <= nc, jj++,
			If( is missing(Column( _dt, selectedcols[jj] )[ii]),
				Column( _dt, selectedcols[jj] )[ii] = Column( _dt, selectedcols[jj] )[ii - 1]
			);
		)
	);
	_nw << Close Window;
);

_nw = New Window( "Fill Down Blanks",
 _tb = Text Box("This script will fill missing values in the columns you select, by using the value in the last previous not empty row for that column"),
	_hb = H List Box(
		_pb = Panel Box( "Select Columns", _lb = List Box( colnames, width( 300 ) ) ),
		_bb = Button Box( "Go", fillcolumns )
	)
);

Names Default To Here(1);

dt3=Current Data Table();
dt3<<Select where(((:x==0) | (Is Missing(:x)))); 
dt3<<delete rows;

dt4=Current Data Table();
dt4<<New Column("a", formula(4));
Column(dt4, "a")<<data type(Numeric)<<Modeling Type(Ordinal);
2 ACCEPTED SOLUTIONS

Accepted Solutions
Thierry_S
Super User

Re: Script skipping order of evaluation

Hi,

You may be able to solve your issue by adding a "Wait (0)" command just before your _nw = New Window statement.

Best,

TS

 

Thierry R. Sornasse

View solution in original post

Craige_Hales
Super User

Re: Script skipping order of evaluation

You need a modal window.

https://www.jmp.com/support/help/en/16.1/?os=win&source=application&utm_source=helpmenu&utm_medium=a... 

"Construct a Modal Window

When you submit a script with a modal window, JMP draws the window, waits for the user to make choices and click OK, and then stores a list of the variables with their values. Any attempt to click outside the window produces an error sound, and script execution is suspended until the user clicks OK or Cancel."

 

You'll find lots of questions and answers about modal windows in the community. At one time, on some OSs, you could refer to variables in a modal window for a short time after the window was closed. That's no longer true. There are several patterns people use for getting variables back...pick one that makes sense to you. The link above uses "return result".

 

edit: new post at Modal Dialogs  might help.

Craige

View solution in original post

2 REPLIES 2
Thierry_S
Super User

Re: Script skipping order of evaluation

Hi,

You may be able to solve your issue by adding a "Wait (0)" command just before your _nw = New Window statement.

Best,

TS

 

Thierry R. Sornasse
Craige_Hales
Super User

Re: Script skipping order of evaluation

You need a modal window.

https://www.jmp.com/support/help/en/16.1/?os=win&source=application&utm_source=helpmenu&utm_medium=a... 

"Construct a Modal Window

When you submit a script with a modal window, JMP draws the window, waits for the user to make choices and click OK, and then stores a list of the variables with their values. Any attempt to click outside the window produces an error sound, and script execution is suspended until the user clicks OK or Cancel."

 

You'll find lots of questions and answers about modal windows in the community. At one time, on some OSs, you could refer to variables in a modal window for a short time after the window was closed. That's no longer true. There are several patterns people use for getting variables back...pick one that makes sense to you. The link above uses "return result".

 

edit: new post at Modal Dialogs  might help.

Craige