Delete dynamic objects
- Last Updated: April 26, 2024
- 2 minute read
- OpenEdge
- Version 13.0
- Documentation
You can delete a dynamic object with the DELETE OBJECT statement:
|
You can also use the WIDGET keyword in place of OBJECT
in this statement. The handle is a variable or temp-table field of type
HANDLE, which was previously used in a CREATE
statement to create the object. If there is no object currently associated with the
handle, the AVM returns an error when it tries to execute the statement. In cases where
your statement might be attempting to delete an object that has not been created or
which has already been deleted, and you do not want to be informed of this at run time,
you can avoid such an error by checking the handle in advance with the
VALID-HANDLE function:
|
Alternatively, you can include the NO-ERROR keyword on the
DELETE statement to suppress any error message:
|
In either case, do not forget the OBJECT keyword. If you do, the AVM
thinks you are trying to delete a record from a table:
|
The following figure shows the result.
It is also important that you understand that you cannot delete a static object using its handle. Consider, for example, this sequence of statements:
|
If you run this procedure you get the error shown in the following figure at run time.
The AVM deletes static objects for you when they go out of scope. You cannot delete them yourself.
Delete windows and frames
If you delete a dynamic frame, any dynamic objects that the frame contains are also deleted. If you delete a dynamic window, any frames that the window contains (both static and dynamic frames) are de-parented from the window and are unrealized. The frames remain valid, and you can re-parent them to another dynamic window.