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),
),
);