Introduction

Language Structure

IB Statements

File System

Comet 32 Runtime

Index

DELETE statement

Syntax: DELETE (lun) KEY=index [,EXCP=statement-label | NOEXCP]
Discussion: The DELETE statement deletes an existing record from a keyed file.

The parameter defines which file the record being deleted from (i.e., the file opened under that lun in a previous OPEN statement).

The index parameter defines the index and associated record being deleted. The index may be a string constant, a single-element string variable, a string array element, a string expression, or a string function.

When the DELETE statement is executed, it automatically advances the file pointer to the next available record in sequential (key) order, marks the record for deletion, and removes the specified key from the key list.

Example 1:
DELETE (3) KEY="ABC-123",EXCP=5000
In this example, a record is deleted from the file opened on logical unit number 3. The key containing "ABC-123" specifies the record to be deleted from the file. If an exception occurs when this statement is executed (e.g., if the key doesn't exist in the file), the program will branch to statement-label 5000.
Example 2:
OPEN (1) "DATAFILE"
.
.
.
PRINT (0) "ENTER KEY TO DELETE:"
INPUT (0) KEYVALUE$
DELETE (1) KEY=KEYVALUE$,EXCP=9999
In this example, the user is prompted for a specific key value. The response is then used to determine which key and record will be deleted from the file opened on logical unit number 1.