DELET

Delete the specified file

WSupported on Windows
USupported on Unix
VSupported on OpenVMS
NSupported in Synergy .NET
xcall DELET(filename)

Arguments

filename

An expression that contains a file specification. See File specifications for details on the format of a file specification. (a)

Discussion

The DELET subroutine locates and deletes the specified file. If the specified file does not exist, no error is generated. However, if the filename is null or blank, a “Bad filename” error ($ERR_FILSPC) occurs.

To delete an ISAM file, you must include the file extension. Both the index and the related data file are deleted.

In previous versions of Synergy DBL, you could also specify a channel argument. This syntax is still valid, but the channel is ignored.

On OpenVMS, filename can contain wildcard characters. The default extension is .ddf. In addition, a given file can have more than one version. If filename does not explicitly specify the version number, all versions of that file are deleted.

Before deleting a file, make sure you first close any channels your program has open to that file.

If the file is open by your program or any other on a system with OS-level locking, when the program calls DELET, a “File in use by another user” error ($ERR_FINUSE) is generated.

Note

In an environment without OS-level locking, having a file open is not necessarily enough to cause DELET to fail. If you have a lock on the file in a way that is evident to Synergy, such as open for exclusive access, DELET will generate an $ERR_FINUSE error as expected. However, with OpenVMS multi-version files, the following will occur:

  • If you DELET the general filename, for example, “FILE.TXT”, OpenVMS will delete all versions of the file that it can access. If any version is open for exclusive access, you will get an error, but the other deletions will still occur. If none are open exclusively, all versions will be deleted.

  • If you DELET a specific filename, for example, “FILE.TXT;1”, OpenVMS will delete only that version of the file. If that version of the file is open for exclusive access, you will get an $ERR_FINUSE error.

Note

When issuing XCALL DELET from an application running on Unix, you must have exclusive access to the file (no process, including the process issuing the DELET, may have the file open), and you must have write permission to both the file itself and the directory. This is more restrictive than what would be allowed from the Unix command line, but it protects Synergy applications from prematurely deleting files that are in use, similar to the behavior on Windows and OpenVMS. If for some reason you need to override this safeguard, use XCALL SPAWN with the Unix rm command to force the command line equivalent.

On Windows, because a virus scanner can take several seconds to scan a file, the DELET routine will retry for up to five seconds before reporting that a file is in use. (The default is 50 1/10th-of-a-second retries, or 5 seconds. You can change the retry count by setting the RETRYTIME environment variable.) The best way to avoid the wait time is to try to open the file exclusively first, so that an $ERR_FINUSE error will occur if the file is being used. This works only if the virus scanner is set to scan on CLOSE or WRITE. If the virus scanner instead performs a default scan of all files on OPEN, READ, and WRITE, an endless loop can occur.

Examples

literal
    file  ,a20,  "DP3:test01.xyz"
proc
    xcall delet(file)
    xcall delet("DM7:demox.tv")
    stop
end