Help with Modal WindowsHi,
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;
Re: Help with Modal WindowsHi 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
Re: Help with Modal WindowsHi gzmorgan,
I havent had time to look at this today, will look at it tomorrow.
Thanks very much for your reply.
Re: Help with Modal WindowsThis 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></MODAL>
Re: Help with Modal WindowsMickyboy,
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, <
- listname["boxname"] so Headstart[ "variablebox" ] returns 3.
- 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=""></RETURN>
Re: Help with Modal WindowsHello,
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());
Re: Help with Modal WindowsFrom 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"