safefileerase
PATH

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


Parameters

This statement has one parameter:

path – is a path to the file to be removed, including the file name (see Files and Folders for more information about file paths).


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, no error will occur – Panorama will simply skip to the next statement in the code.

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"

See Also


History

VersionStatusNotes
10.0UpdatedCarried over from Panorama 6.0 but now uses a 1 parameter syntax and has a new name. (The old name and 2 parameter syntax is still available.)