I have been trying to close new windows but am successful, for arguments sake, I tried x = New Window( *some code*);
Close(x);
x << Close();
x << Close;
x << Close Window();
Any help would be greatly appreciated
<< Close Window; or << Close Window(); should work
Names Default To Here(1);
nw = New Window("");
wait(2);
nw << Close Window();
Here is a slightly more complicated example showing how to close a non-modal window with either the OK or Cancel buttons.
nw = new window("Test",
textbox("Hello World"),
panelbox("Actions",
hlistbox(
okb = button box("OK", << set icon("Go"),
set script(
show("Clicked OK");
// Other OK actions here
nw << close window();
),
),
canb = button box("Cancel", << set icon("Stop"),
set script(
show("Clicked Cancel");
nw << close window();
),
),
)
)
);
<< Close Window; or << Close Window(); should work
Names Default To Here(1);
nw = New Window("");
wait(2);
nw << Close Window();
For syntax questions such as you are asking, you can find your answers in the Scripting Index.
Help=>Scripting Index
Here is a slightly more complicated example showing how to close a non-modal window with either the OK or Cancel buttons.
nw = new window("Test",
textbox("Hello World"),
panelbox("Actions",
hlistbox(
okb = button box("OK", << set icon("Go"),
set script(
show("Clicked OK");
// Other OK actions here
nw << close window();
),
),
canb = button box("Cancel", << set icon("Stop"),
set script(
show("Clicked Cancel");
nw << close window();
),
),
)
)
);
Here's another wrinkle with regard to closing windows. Let's say you have a dataset open and when the user clicks OK or Cancel there is an action to close the dataset. But what if the user clicks the close window button (X in upper right)? The on close() function takes care of it. Here's an example:
// Build a display window for ftab_box
ftab_window = New Window("Frequency Tab", << on close(close(ftab_dataset, nosave)),
H List Box(
Button Box("Save to MSWord",
ftab_output << Save MSWord("", Native);
),
Text Box( " " ),
Button Box( "Close this Window",
ftab_window << CloseWindow;
// close(ftab_dataset, nosave); // This gets run by on close above
),
),
ftab_output = vlistbox(
outlinebox(ftab_title,
ftab_box),
),
);