Share your ideas for the JMP Scripting Unsession at Discovery Summit by September 17th. We hope to see you there!
Choose Language Hide Translation Bar
Highlighted
zjuv007
Level III

How do I hault code execution until the user selects the first set of data to filter?

I have a window to prompt the user to filter based on model numbers they'd like to choose, the problem is that I think this window is getting overwritten and causing an error when it runs all of the way through, so I'd like it to first stop, display the window, and wait  for the user to input their choices. Here's the window script:

//*** Create a window to prompt user to filter for Model numbers they would like to use
	prods = Associative Array( Column( dt2, "Product CFN" ) << getValues ) << getKeys;
	nw1 = New Window( "2014 Product Filter", lb1 = List Box( prods ), Button Box( "OK", OKscript2014 ) );
	OKscript2014 = Expr(
		SelectedProds = lb1 << getSelected;
		selectedRows = [];
		For( p = 1, p <= N Items( SelectedProds ), p++,
			selectedRows = V Concat( selectedRows, dt2 << getRowsWhere( :Product CFN == SelectedProds[p] ) )
		);
		dt5 = dt2 << Subset( Rows( selectedRows ), LinkToOriginalDataTable( 0 ) );
		Wait( 0 );
		dt5 << Save( dir || "\PrimaryRFR_ProductFiltered_2014.jmp" );
	);

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted

Re: How do I hault code execution until the user selects the first set of data to filter?

Make the window modal - that halts all code execution until the window is closed. You'll also need to move the definition of the script in the button in the window above the window itself. Example:

 

prods = Associative Array( Column( dt2, "Product CFN" ) << getValues ) << getKeys;
OKscript2014 = Expr(
	SelectedProds = lb1 << getSelected;
	selectedRows = [];
	For( p = 1, p <= N Items( SelectedProds ), p++,
		selectedRows = V Concat( selectedRows, dt2 << getRowsWhere( :Product CFN == SelectedProds[p] ) )
	);
	dt5 = dt2 << Subset( Rows( selectedRows ), LinkToOriginalDataTable( 0 ) );
	Wait( 0 );
	dt5 << Save( dir || "\PrimaryRFR_ProductFiltered_2014.jmp" );
);
nw1 = New Window( "2014 Product Filter", <<Modal, lb1 = List Box( prods ), Button Box( "OK", OKscript2014 ) );

View solution in original post

3 REPLIES 3
Highlighted

Re: How do I hault code execution until the user selects the first set of data to filter?

Make the window modal - that halts all code execution until the window is closed. You'll also need to move the definition of the script in the button in the window above the window itself. Example:

 

prods = Associative Array( Column( dt2, "Product CFN" ) << getValues ) << getKeys;
OKscript2014 = Expr(
	SelectedProds = lb1 << getSelected;
	selectedRows = [];
	For( p = 1, p <= N Items( SelectedProds ), p++,
		selectedRows = V Concat( selectedRows, dt2 << getRowsWhere( :Product CFN == SelectedProds[p] ) )
	);
	dt5 = dt2 << Subset( Rows( selectedRows ), LinkToOriginalDataTable( 0 ) );
	Wait( 0 );
	dt5 << Save( dir || "\PrimaryRFR_ProductFiltered_2014.jmp" );
);
nw1 = New Window( "2014 Product Filter", <<Modal, lb1 = List Box( prods ), Button Box( "OK", OKscript2014 ) );

View solution in original post

Highlighted
zjuv007
Level III

Re: How do I hault code execution until the user selects the first set of data to filter?

Thank you! Is there also a way to make this window stay front and centered to the user? So as to not have it get overdisplayed by another data table?

Warm regards,
Zach
Highlighted

Re: How do I hault code execution until the user selects the first set of data to filter?

A modal window should always be on top. If you have other windows displaying over top of a modal window, I recommend that you call tech support. A non-modal window will not always be on top. You can send a non-modal window the << bring window to front message.

Article Labels

    There are no labels assigned to this post.