Syntax

Ends a record: runs its Delete method, if it has one, then marks the record as deleted.

DELETE <variable>
DELETE <array>[<index>]
DELETE <record>.<field>
METHOD Delete()

Parts

<variable>A variable that holds a record. It is emptied (NULL) after the call.
<array>An array of records.
<index>The cell to delete, in square brackets.
<record>A record that has a record field.
<field>The record field to delete.

Good to know

  • After DELETE on a variable, reading one of its fields stops the program.
  • On an array cell or a field, the cell stays, but calling one of its methods stops the program: "BASIC record has been deleted".
  • The path takes square brackets: DELETE fleet[2]. DELETE fleet(2) is refused: "DELETE requires a BASIC record variable or field".
  • Deleting the same record twice stops the program: "BASIC record has been deleted".
  • Delete runs only through DELETE. Reassigning a variable, or reaching the end of the program, does not call it.
  • DELETE on a number variable is not refused. The variable silently becomes NULL, or the program stops if it held 0. Use it on records only.

Example

alive = 0TYPE Enemy  hp AS integer  METHOD New()    alive = alive + 1  ENDMETHOD  METHOD Delete()    alive = alive - 1  ENDMETHODENDTYPEe AS Enemyf AS EnemyConsole(Str(alive))   ' 2DELETE eConsole(Str(alive))   ' 1
In the manual : Records and methods