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;
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,
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);
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,
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);
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);
Hello,
I am trying to understand why the JMP Button Box("OK") structure from examples works as it does.
Is it a predefined result that if text is "OK" then "Button"=1, and any other text then "Button"=-1.
My code is based on the JMP help, and similar to gzmorgan code of this discussion.
LineupBox( NCol(1), ButtonBox("OK"), ButtonBox("Cancel"))
If(usr_info["Button"]== -1,
Caption("Aborting..."); Wait(3); Caption(Remove); Throw());
From JMP Online Help
Note: Modal windows require at least one button for dismissing the window. You can use OK, Yes, No, or Cancel to label modal window buttons. If you do not include at least one of these buttons in a modal window, JMP adds an OK button.
The built-in functionality of a Modal display window returns a +1 for "OK" or "Yes" and a -1 for "Cancel" and "No"
Hi gzmorgan,
I havent had time to look at this today, will look at it tomorrow.
Thanks very much for your reply.
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