DELETESEQ Statement
Deletes a host file or Reality item previously opened for sequential access, and maintains the lock.
Syntax
DELETESEQ seqfile-var {SETTING setting-var } {ON ERROR statement(s) } [ THEN statement(s) | ELSE statement(s) ]
Syntax Elements
seqfile-varis the name of a variable containing a sequential file reference (assigned via an OPENSEQ statement).
setting-varThe name of a variable to which the return status is assigned. See Operation for details of the possible values for this variable.
statement(s)A sequence of one or more valid DataBasic statements, either separated by semicolons, or contained on separate lines and followed by an END statement.
Operation
The following details circumstances under which the different clauses are executed and the values returned in setting-var:
Clause Executed |
Reason |
setting-var |
STATUS() Value |
---|---|---|---|
THEN |
File or item successfully deleted |
0 |
0 |
ELSE |
File or item does not exist |
2040 |
206 |
ON ERROR |
File or item opened, but not for sequential access (not opened with OPENSEQ) |
B45 |
12 |
|
File or item not open |
B12 |
12 |
|
General file error |
Error number |
Error number |
Note
-
If an error occurs but there is no ON ERROR clause, the DataBasic Debugger will be entered with error B53 as well as the setting-var value.
-
The final column gives the values returned by the STATUS function if this is used instead of a SETTING clause.
Comments
When calling this statement, you need to be aware of the effects of any file triggers that might run as a consequence. See File Triggers for more information.
It is recommended that you always include an ON ERROR clause. If you do not and an error occurs at run time, your program will abort. This is particularly important if the file has a PRE-DELETE trigger that may cancel the DELETE operation.
Example
OPENSEQ "/usr/pauls/qa4" TO SF1 THEN DELETESEQ SF1 THEN NULL END CLOSESEQ SF1
This program opens the host file /usr/pauls/qa4 and saves a reference to the open file in variable SF1. If the file exists, it is deleted and then closed (to release the lock).
See Also
OPENSEQ statement, CLOSESEQ statement, READSEQ statement, READBLK statement, WRITESEQ statement, WRITEBLK statement, SEEK statement, WEOFSEQ statement.