Destroying an object (destroy)


Destroy an object


destroy object_id [, object_id]…

Destroy the object or objects specified, freeing the memory allocated to them.

The object can be re-created by means of the create command, which creates the object as new, including any run time changes to visible properties which are now effected for the first time.

If the winclass, menu style or menu label clause properties are changed at run time, using the form:

object_id->property = value

the window or object must first be destroyed. The new value is used when the object is next created.

If the xcreate | ycreate properties are changed, the window or object does not need to be destroyed, but the changes do not take effect until the next time the object is created.

It is not necessary to destroy or re-create an object if any other properties are changed. If possible, Sculptor changes the property without destroying the object. Otherwise, if the object is currently in the created state, Sculptor destroys it and re-creates it with the new property value(s). Windows are an exception to this rule; Sculptor does not destroy and re-create them automatically. The programmer must do so.

When a window or object is created, the EV_DESTROY event is generated for it. See Event functions.

The object to be destroyed may be any of the following:


A window. All objects within the window are also destroyed. The main task window wintask must not be destroyed.


A textbox group or button group. All the objects within the group are destroyed.

box_id, button_id, graphic_id, listbox_id, menu_id, table_id, text_id

A single object.

Different object types may be freely mixed in a destroy command.


  • The hide command removes objects from view but does not destroy them.


  1. Destroy a window and all objects contained in it

    destroy Window1
  2. Destroy all buttons in the group Stylegroup

    destroy MyWindow.StyleGroup
  3. Destroy two objects

    destroy TextBox1, NamesList