Global Navigation Bar

MapInfo Products Knowledge Base


Product: MapBasic
Version: 6.5
Platform: Not Platform Related
Category: Documentation

Summary:
TempFileName$( ) function - Description.

Question:
What does the TempFileName$( ) function do?

Answer:
Purpose

Returns a name that can be used when creating a temporary file.

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 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.

See Also

File input/output

Last Modified:
Global Navigation Bar