Release 10.1A: OpenEdge Development:
Progress 4GL Handbook

> ## Deleting dynamic objects

> You can delete a dynamic object with the `DELETE OBJECT` statement:

>     DELETE OBJECT handle.

> 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, Progress 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 don’t 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:

>     IF VALID-HANDLE(hButton) THEN
>          DELETE OBJECT hButton.

> Alternatively, you can include the `NO-ERROR` keyword on the `DELETE` statement to suppress any error message:

>     DELETE OBJECT hButton NO-ERROR.

> In either case, don’t forget the `OBJECT` keyword. If you do, Progress thinks you’re trying to delete a record from a table:

>     DEFINE VARIABLE hButton AS HANDLE       NO-UNDO.
>            .
>            .
>            .
>     DELETE hButton.       /* Don’t do this! */

> Figure 18–6 shows the result.

> Figure 18–6: Unknown table error message

> It’s also important that you understand that you cannot delete a static object using its handle. Consider, for example, this sequence of statements:

>     DEFINE VARIABLE hButton AS HANDLE       NO-UNDO.
>     DEFINE BUTTON MyButton.
>     DISPLAY MyButton.
>     hButton = MyButton:HANDLE.
>     DELETE OBJECT hButton.

> If you run this procedure you get the error shown in Figure 18–7 at run time.

> Figure 18–7: Static handle error message

> Progress deletes static objects for you when they go out of scope. You cannot delete them yourself.

Copyright © 2005 Progress Software Corporation www.progress.com Voice: (781) 280-4000 Fax: (781) 280-4095