Platform: Not Platform Related
TempFileName$( ) function - Description.
What does the TempFileName$( ) function do?
Returns a name that can be used when creating a temporary file.
TempFileName$( dir )
dir is the string that specifies the directory that will store the file; "" specifies the system temporary storage directory.
Returns a string that specifies a unique file name, including its path.
Use the TempFileName$( ) function when it is necessary to create a temporary file, but it is not known what file name to use.
When calling 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 trying 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 the 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.