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
Mickyboy
Level V

Help with Modal Windows

Hi,

 

l am trying to set up dialog boxes in existing scripts, the first is the location of headers in the data l am importing.

 

l understand the following will give me a nice Display box:

 

Headstart = New Window( "Set Header Start Row Value",
<< Modal,
<< Return Result,
Text Box ("Please advise the row on which the header starts"),
variablebox = Number Edit Box ( 2 ),
Button Box ( "OK "),
Button Box ( "Cancel" ) 
);

 

Does the next piece of syntax then write the user reply to Headstart

 

Write ( Headstart ["variablebox"]);

How do l actually get to use the value stored in the Headstart, have tried the below:

//dt=open(fileopen,private);
dt = Open(

fileopen,
Worksheets( "Lin" ),

Worksheet Settings(
1,
Has Column Headers( 1 ),
Number of Rows in Headers( 1 ),
Headers Start on Row( "Headstart" ),
Data Starts on Row( 37 ),
Data Starts on Column( 1 ),
Data Ends on Row( 48 ),
Data Ends on Column( 15 ),
Replicated Spanned Rows( 1 ),
Replicated Spanned Headers( 0 ),
Suppress Hidden Rows( 1 ),
Suppress Hidden Columns( 1 ),
Suppress Empty Columns( 1 ),
Treat as Hierarchy( 0 ),
Multiple Series Stack( 0 ),
Import Cell Colors( 0 ),
Limit Column Detect( 0 ),
Column Separator String( "-" )

),
);
 
Datasource = fileopen;
1 ACCEPTED SOLUTION

Accepted Solutions
gzmorgan0
Super User (Alumni)

Re: Help with Modal Windows

Mickyboy,

 

If I entered 3, show(Headstart) returns the list {variablebox = 3, Button( 1 )}. Except for the Button, every other item in the list is an assignment. 

 

Here are two ways to get the values from a modal dialog, <<Return Result,

  1.  listname["boxname"]  so Headstart[ "variablebox" ] returns 3.
  2.  If the button is 1, remove the last item in the list, and eval list(listname), then each assignment is executed and you can refer to the variablebox name. 

Below is an excerpt from script 7_SimpleModalDialog.jsl, one of the scripts written for JSL Companion, Applications of the JMP Scripting Language, 2nd edition. The first show statement uses the syntax #2 and the second show is teh syntax you can use after you remove the button and eval list().

 

There are additional methods as well.

 

So for your example,  you can use 

   Headers Start on Row( Headstart["variablebox"] )

or use code similar to the example below.

 

 

 

Names Default to here(1);

usr_info = New Window("Query", << Modal, <<Return Result,
	    Text Box("Select the query filters"), 
	    HListBox(
	      LineupBox(NCol(2),
	    	TextBox("Number of days, 30 day maximum"), ndays = numberEditBox(7),
			TextBox("Parameter name, wildcard=* "), param = textEditBox(),
			TextBox("Manufacturing Step Id"), step_id = numberEditBox()
		  ), //end LineupBox 
		  LineupBox( NCol(1), ButtonBox("OK"), ButtonBox("Cancel"))
		) //end HListBox
);

show(usr_info, usr_info[ "ndays" ], usr_info["param"], 
      usr_info["step_id"], usr_info["Button"] );
      
      
//Review chapter 5 on Lists and Assignment Lists. This output is an assignment list, except for Button()
//Usage: usr_info["ndays"] contains user repsonse or Check for OK , remove button and Eval List
If(usr_info["Button"]== -1, 
   Caption("Aborting..."); Wait(3); Caption(Remove); Throw());
StatusMsg("Processing next steps");
RemoveFrom(usr_info, NItems(usr_info));   //Remove the last item "Button(1)"
Eval List(usr_info);                      //Assignments are run
Show( usr_info, ndays, param, step_id);

 

 

 

 

 

View solution in original post

4 REPLIES 4
gzmorgan0
Super User (Alumni)

Re: Help with Modal Windows

Mickyboy,

 

If I entered 3, show(Headstart) returns the list {variablebox = 3, Button( 1 )}. Except for the Button, every other item in the list is an assignment. 

 

Here are two ways to get the values from a modal dialog, <<Return Result,

  1.  listname["boxname"]  so Headstart[ "variablebox" ] returns 3.
  2.  If the button is 1, remove the last item in the list, and eval list(listname), then each assignment is executed and you can refer to the variablebox name. 

Below is an excerpt from script 7_SimpleModalDialog.jsl, one of the scripts written for JSL Companion, Applications of the JMP Scripting Language, 2nd edition. The first show statement uses the syntax #2 and the second show is teh syntax you can use after you remove the button and eval list().

 

There are additional methods as well.

 

So for your example,  you can use 

   Headers Start on Row( Headstart["variablebox"] )

or use code similar to the example below.

 

 

 

Names Default to here(1);

usr_info = New Window("Query", << Modal, <<Return Result,
	    Text Box("Select the query filters"), 
	    HListBox(
	      LineupBox(NCol(2),
	    	TextBox("Number of days, 30 day maximum"), ndays = numberEditBox(7),
			TextBox("Parameter name, wildcard=* "), param = textEditBox(),
			TextBox("Manufacturing Step Id"), step_id = numberEditBox()
		  ), //end LineupBox 
		  LineupBox( NCol(1), ButtonBox("OK"), ButtonBox("Cancel"))
		) //end HListBox
);

show(usr_info, usr_info[ "ndays" ], usr_info["param"], 
      usr_info["step_id"], usr_info["Button"] );
      
      
//Review chapter 5 on Lists and Assignment Lists. This output is an assignment list, except for Button()
//Usage: usr_info["ndays"] contains user repsonse or Check for OK , remove button and Eval List
If(usr_info["Button"]== -1, 
   Caption("Aborting..."); Wait(3); Caption(Remove); Throw());
StatusMsg("Processing next steps");
RemoveFrom(usr_info, NItems(usr_info));   //Remove the last item "Button(1)"
Eval List(usr_info);                      //Assignments are run
Show( usr_info, ndays, param, step_id);

 

 

 

 

 

pmroz
Super User

Re: Help with Modal Windows

This approach may be a little easier to understand.  Put actions you want to happen in the OK and Cancel buttons.

hw = New Window( "Set Header Start Row Value", <<Modal,
	Text Box( "Please advise the row on which the header starts" ),
	variablebox = Number Edit Box( 2 ),
	hlistbox(
		Button Box( "OK ",
			headstart = variablebox << get),
		Button Box( "Cancel",
			headstart = -999;),
	)
);
if (headstart == -999,
	throw("Cancel clicked")
);
show(headstart);
Mickyboy
Level V

Re: Help with Modal Windows

Hi gzmorgan,

 

I havent had time to look at this today, will look at it tomorrow.

 

Thanks very much for your reply.

 

 

Mickyboy
Level V

Re: Help with Modal Windows

Hi gzmorgan0,

 

l finally had a chance to do this today, it worked a treat, thank you so much, l am new to coding in JMP, and people like you are making the learning experience a hell of alot easier, and alot less fustrating, i cant thank you enough.

 

Thanks again