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.
The Column Dialog() function is specifically intended to prompt users to choose columns from the current (topmost) data table. Windows created by Column Dialog() are also modal windows.
win = New Window( "Set a Value",
<<Modal,
Text Box( "Set this value" ),
variablebox = Number Edit Box( 42 ),
Button Box( "OK" ),
Button Box( "Cancel" )
);
Notice that the argument to Number Edit Box() is the default value, 42.
Figure 11.35 Sample Modal Display Box
If you click OK, the window closes and {Button(1)} is returned. To get the value entered in the box, use the Return Result message and a subscript into the window. Note that the deprecated Dialog() returns the list of variable assignments the same way.
win = New Window( "Set a Value",
<<Modal,
<<Return Result,
Text Box( "Set this value" ),
variablebox = Number Edit Box( 42 ),
Button Box( "OK" ),
Button Box( "Cancel" )
);
Write( win["variablebox"] );
// create a subscript to the variablebox variable
If( win["Button"] == 1,
Print( win["variablebox"] );
,
Print("Canceled")
);
Note that a modal window must have at least one button. If you omit the Button Box() from your script, an OK button is automatically included. To omit the OK button, set the visibility to collapse.
win = New Window( "No OK Button",
<<Modal,
b = Button Box( "Close Window", b << Close Window ),
bb = Button Box( "OK", <<Visibility( "collapse" ) )
);
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.