2.12 :delete()

There are three different forms of the :delete() method:

2.12.1 :delete() (List Objects)

This method deletes rows and columns from the contents of an object whose contents consist of multiple entries indexed with integer or index. Along with the contents, the associated attributes are deleted as well.

Unlike the :clear() method, with :delete() rows or columns are deleted completely, i.e. the number of rows or columns will be reduced by :delete().

Definition

boolean :delete
(
      integer Position input
  { , integer Count := 1 input }
  { , boolean Direction := false input }
)

Parameters

integer Position input
This parameter defines the position from which the rows or columns should be deleted.
integer Count := 1 input
This optional parameter defines the number of rows or columns that are deleted. If the parameter is not specified, 1 is taken as default.
boolean Direction := false input

This optional parameter controls whether rows or columns are deleted in the tablefield. This depends on the value of the tablefield attribute .direction.

The parameter may only be passed for the tablefield. For other objects than the tablefield, passing the parameter will result in an error.

Value range

false
Deletes against the direction given in the .direction attribute
true
Deletes in the same direction as given in the .direction attribute

Thus these contents are deleted from the tablefield:

Parameter Direction

.direction 1 (vertical)

.direction 2 (horizontal)

false

row(s)

column(s)

true

column(s)

row(s)

Return value

The method returns true if the rows or columns could be deleted.

If an error has occurred when deleting, the method will return a fail.

Objects with this method

Example

dialog D

window Wn
{
  .title "Example for the method :delete()";

  child treeview Tv
  {
    .content[1] "Company A";
    .content[2] "Miller";
    .content[3] "Mayer";
    .content[4] "Company B";
    .content[5] "Jones";
    .content[6] "Smith";
    .content[7] "Fisher";
    .style[style_lines]   true;
    .style[style_buttons] true;
    .style[style_root]    true;
    .level[2] 2;
    .level[3] 2;
    .level[5] 2;
    .level[6] 2;
    .level[7] 2;
  }

  child pushbutton Pb
  {
    .text "Remove an employee";

    on select
    {
      Tv:delete(Tv.activeitem);
    }
  }
}

2.12.2 :delete() (Arrays)

This method deletes items from arrays (indexed user-defined attributes).

Unlike the :clear() method, :delete() completely deletes the elements, i.e. the number of elements is reduced.

Definition

boolean :delete
(
      attribute Attr input,
      anyvalue Position input
  { , integer Count := 1 input }
)

Parameters

attribute Attr input
This parameter defines the user-defined attribute on which the method should be applied.
anyvalue Position input

In this parameter the index of the first item to be deleted is passed. For non-associative arrays Position has to be of the data type integer, for associative arrays it has to be of the data type the associative array is indexed with.

The value range for Position with non-associative fields is 0 … .count[Attr], i.e. the default value can also be deleted. If the default value is deleted, the value of the first item after the deleted items becomes the default value.

integer Count := 1 input

This optional parameter defines the number of items that are deleted. If the parameter is not specified, 1 is taken as default.

Count cannot be used with associative arrays, only 1 item can be deleted at once.

Return value

The method returns true if the rows or columns could be deleted.

If an error has occurred when deleting, the method will return a fail.

Objects with this method

All objects that may have user-defined attributes.

See also

Chapter “Methods for Arrays of User-defined Attributes” in manual “User-defined Attributes and Methods”

Chapter “Working with Associative Arrays” in manual “User-defined Attributes and Methods”

2.12.3 :delete() (doccursor)

This method deletes the DOM node that the XML Cursor points to with all of its child nodes from an XML Document. The XML Cursor is then positioned to the parent node. XML Cursors, which point to the deleted DOM nodes in the sub-tree, become invalid. The attribute .mapped has the value false for invalid XML Cursors.

If the value of the .path attribute is stored elsewhere (e.g. in the .userdata attribute), it should be noted that the stored value is not adjusted when the structure of the DOM tree changes. When the :select method is invoked with the stored value afterward, the XML Cursor may be pointing to an incorrect DOM node.

Definition

boolean :delete
(
)

Parameters

None.

Return value

true
The DOM node could be deleted.
false
An error occurred during deletion.

Objects with this method

doccursor