trapclose

It is important for Just BASIC program windows to trap the close event. Then when a user tries to close a window, program flow is directed to an event handler that the program specifies. At that place the program can ask for verification that the window should be closed, and/or perform some sort of cleanup (close files, write ini data, set a flag that the window is open or closed, etc.).  There may be a menu item or button that a user can click to close the window, but the user might also click the X closing button or the system close button, and that is the event trapped by the trapclose statement.

The trapclose command works with all window types.

Here is the format for trapclose:

  print #myWindow, "trapclose [branchLabel]"

  print #myWindow, "trapclose subLabel"

  #myWindow "trapclose [branchLabel]"