Function GetUniqueFileName() Foundation
Creates a unique name for a file.
GetUniqueFileName( [<cPath>], [<cPrefix>] ) --> cFileName
GetUniqueFileName() returns a file name that is unique within the directory specified. The file name is returned including path information.
The function GetUniqueFileName() creates a unique file name. It can be used for creating temporary files using the low-level file functions, for example. The file name returned is comprised of a prefix (3 characters) and a number in hexadecimal format. The exact format of the file name returned is platform-dependent. Generally, it conforms to the following convention:
"<cPath>\<cPrefix><number>.TMP"
// The example uses GetUniqueFileName() to create
// a temporary file
PROCEDURE Main()
LOCAL cFileName
LOCAL nFile
LOCAL cData := "Test data for temporary file"
cFileName := GetUniqueFileName( , "TST" ) // Sample return: "C:\TEMP\TST94.TMP"
nFile := FCreate( cFileName )
IF nFile == -1
Alert( "Can't create temporary file!" )
QUIT
ENDIF
FWrite( cData, Len(cData) )
FClose( nFile )
WAIT "Temporary file " + cFileName + " created. Please press a key."
RETURN
If you see anything in the documentation that is not correct, does not match your experience with the particular feature or requires further clarification, please use this form to report a documentation issue.