safefiletrash
FOLDER
,
FILE

The safefiletrash statement deletes a file if it exists, but no error if it doesn’t exist.


Parameters

This statement has two parameters:

folder – Folder that contains the file.

file – Name of file.


Description

This statement erases a disk file or a folder, removing it from the hard disk. When using this statement to delete files or folders, realize that you are permanently removing them from the hard disk; this statement does not move them to the Trash where they can be recovered later. There is no error if the file does not exist.

If the file to be erased has an extension, you must include the extension in the file name. If you wish to erase a Panorama X database, you must include the .pandb extension in the file name, even if it is not shown. Failure to do so will could delete the wrong file or even an entire folder and its contents.

This example deletes a file named Addresses.pandb in the Documents folder.

safefileerase "~/Documents/Addresses.pandb"

If the Documents folder had contained a folder called Addresses and you omitted the .pandb extension from the file name above, the Addresses folder would be deleted.

This example deletes a file named demo.txt in the Documents folder.

safefileerase "~/Documents/demo.txt"

If the file does not exist, an error will occur. If you are not sure if the file exists, you may want to test for the error.

safefileerase "~/Documents/demo.txt"
if error
    ... handle the error
endif

If the procedure issuing the fileerase cammand is in the same folder as the file to be erased, it is not necessary to specify the file path, as in this example:

safefileerase "demo.txt"
Legacy Two Parameter Syntax

Previous versions of Panorama (version 6 and before) used a two parameter format for the filetrash statement:

safefiletrash folder,filename

For compatibility with existing databases, this format still works. Here is an example:

safefiletrash dbsubfolder("Logs"),datepattern(today(),"YYYYMMDD")+".log"

History

VersionStatusNotes
1.0No ChangeCarried over from Panorama 6.0.