New Window() and Column Dialog() enable you to construct a launch window that has a column selector. Use Column Dialog() to construct a simple launch window. Several items are added automatically to column dialogs: the Remove and Cancel buttons, the list of columns, and an OK button (if no buttons are explicitly defined).
dt = Open( "$SAMPLE_DATA/Big Class.jmp" );
dlg = Column Dialog(
x = ColList( "X", Max Col( 1 ) ),
y = ColList( "Y", Max Col( 1 ) )
);
Show( dlg );
// returns dlg = {x = {:weight}, y = {:height}, Button(1)};
If( dlg["Button"] == 1,
xCol = dlg["x"];
yCol = dlg["y"];
);
Show( xCol, yCol );
// returns xCol = {:height};
// returns yCol = {:weight};
New Window() is more flexible because of numerous optional arguments. In the following example, the user must select two columns before clicking the OK button. A Bivariate graph is then created. Validating the user’s selections is not possible in Column Dialog().
dt = Open( "$SAMPLE_DATA/Big Class.jmp" );
xvar = .;
yvar = .;
win = New Window( "Example of Returning Values",
<<Modal,
<<On Validate(
// require the user to select two variables before clicking OK
Show( xvar, yvar );
If( Is Missing( xvar ) | Is Missing( yvar ),
// if xvar or yvar are missing do nothing when OK is clicked
0,
1
);
),
Text Box( " Select two numeric columns. " ),
H List Box(
Text Box( " X, Factor " ),
x = Col List Box(
dt, // data table reference
all, // display all columns from the data table
xvar = (x << Get Selected)[1];
// get the name of the selected column before the window closes
Show( xvar );
),
Text Box( "Y, Response" ),
y = Col List Box(
dt,
all,
yvar = (y << Get Selected)[1];
Show( yvar );
)
)
);
If (win["Button"] == 1, // if the user clicks OK...
xcol = Column( dt, xvar ); // get the columns
ycol = Column( dt, yvar );
dt << Bivariate( Y( ycol ), X( xcol ) ); // create a Bivariate plot
);