## The `Close' method

Argument: Optional boolean scalar - see text
Result: None

Valid for: Any object except System, but usually applies only to Form, Window, Document, Dialog, APL, SendMail, GetMail, Socket, and Printer objects

The `Close` method is used to request an object to close itself.

#### Window-level and other visible objects

For a Window, Form, Dialog or Document, and for other visible objects, the exact behavior depends on the event handler state and the argument to the `Close` method.

- If the `Close` method is invoked with an argument of 1, the object is closed unconditionally (but not destroyed), and the `onClose` callback (if any) is not invoked.
- If the `Close` method is invoked without an argument (or with an argument of 0), and if an `onClose` callback has been defined for the object, the `onClose` callback will be triggered. This callback function - which you supply - will normally do any processing necessary when the object is closed (such as saving the state of the window), and then actually close the object by invoking the `Close` method again with an argument of 1, or alternatively destroy it altogether using the `Delete` method. In some cases, however, the object may 'refuse' to close itself; for example, the `onClose` callback function might put up a dialog box to ask the user to confirm that he wishes to close the window, and if not then the window is not closed.
- If no `onClose` callback has been defined for an object, the default behavior is to close the object immediately, whether or not an argument was supplied to the `Close` method.
- If the object is already in the closed state the `Close` method has no effect at all.

When an object is closed it is no longer visible, but it still exists. You can still read or set its properties, and it can subsequently be re-opened in the same state by using the `Open` method. However, you should remember that a closed object continues to use system memory, and therefore if an object is not going to be needed again you should destroy it altogether (using the `Delete` method) as soon as you can, for example at the end of the `onClose` callback function.

For a Form, Dialog, Window or Document object, invoking the `Close` method without an argument has the same effect as the user clicking in the close box in the window's title bar.

#### Printer object

For a Printer object, the `Close` method has a special effect. The current print job is closed, and submitted to the printer. The method takes no argument.

#### APL (child task) object

For an APL object, the `Close` method terminates the child task, closing any windows belonging to the task and freeing the workspace memory. The method takes no argument.

#### Networking objects

For the SendMail, GetMail and Socket objects, the `Close` method closes the connection and releases resources at the other end. It takes no arguments. You should always ensure you call the `Close` method when the communications session is complete.

Topic: APLX Help : System Classes : Methods : Close

[ Previous | Next | Contents | Index ]