Purpose
Returns a name that can be used when creating a temporary file. You can call this function from the MapBasic window in MapInfo Pro.
Syntax
TempFileName$( dir )
dir is the string that specifies the directory that will store the file; "" specifies the system temporary storage directory.
Return Value
Returns a string that specifies a unique file name, including its path.
Description
Use the TempFileName$() function when you need to create a temporary file, but you do not know what file name to use.
When you call TempFileName$(), MapBasic returns a string representing a file name. The TempFileName$() function does not actually create the file. To create the file, issue an Open File statement.
If the dir parameter is an empty string (""), the returned file name will represent a file in the system's temporary storage directory, such as "G:\TEMP\~MAP0023.TMP".
In a networked environment, it is possible that two users could attempt to create the same file at the same time. If you try to create a file using a filename returned by TempFileName$(), and an error occurs because that file already exists, it is likely that another network user created the file moments after your program called TempFileName$(). To reduce the likelihood of such file conflicts, issue the Open File statement immediately after calling TempFileName$(). To eliminate all chances of file sharing conflicts, create an error handler, and enable the error handler (by issuing an OnError statement) before issuing the Open File statement.
See Also:
FileExists() function