The delete() method deletes an instance of a class. This function does not delete objects that are related to the deleted object. ASL creates an error if the object handle used with the delete() method points to an object that does not exist. The syntax of the delete() method is:

         <objectRef>->delete();

You can use += or -= operators to add or delete an object from a list of object handles in ASL or from a relationshipset in MODEL. “Modifying relationshipsets” on page 111 provides additional information.

The following script deletes a card and its related ports. The script contains a default variable that specifies the card to delete. When the ComposedOf relationship is used, the ASL script creates a list of port objects to delete. The card is deleted first, followed by its ports. Exception handling causes the script to stop if the card object does not exist.

ASL Script (delete_obj.asl):
default delthis = "CARDX";
START {
 ..eol
}
do {
 delthisObj = object(delthis);
 relObj = delthisObj->ComposedOf?LOG,STOP;
 x = delthisObj->delete();
 foreach mem (relObj)
  {
  mem->delete();
  }
 print("Deleted ".delthis." and related ports");
}
Input:
none
Output:
$ sm_adapter --server=JS1 -Ddelthis="CARD2" delete_obj.asl
Deleted CARD2 and related ports
$