Returning a unique temporary file name¶
tempname() |
Return a unique temporary file name |
SYNTAX
tempname(prefix)
Returns a unique temporary filename.
The prefix may be a null string (“”), in which case the filename is of the format:
“zzXXXXXX”
where the operating system replaces the XXXXXX with letters and numbers which guarantee a unique filename.
If a prefix is provided, function returns a filename with the format:
“prefixXXXXXX”
the XXXXXX again representing six letters and numbers which, together with the prefix, form a unique filename.
Under MS-DOS, the maximum length of a filename is 8.3. Therefore, the prefix should be restricted to 2 characters if the programmer intends to add an extension to the filename returned by the function. If no extension is to be added, the prefix may be up to 5 characters long.
The function returns the temporary filename. If no unique filename could be generated, a null string is returned.
NOTES
The function does not create the file.
If this function is called twice, the same filename can be returned, provided that the file returned by the first call is not created before the second call is made. This is standard system behaviour.
EXAMPLES
open #5, tempname("") create traps = OPENTRAP
tmp.FileName = tempname("tmp")
if (RFTempName = "") { RFTempName = tempname("RF") display TempNameBox }
RELATED TOPICS |