TmpNam()

Description

TmpNam() is used to return a string containing a `safe' temporary filename as per the C function tmpnam().

Call Signature

string TmpNam ( [ string location, string extension] )

Return Value

string

The temporary file name.

Arguments

[ string location ]:

If this argument is present, this is the location for the temporary file. This can be either a directory name or a file name from which the path will be extracted.

[ string extension ]:

If this argument is present, this is the extension for the temporary file. If missing, the default extension used is ".tmp".

Remarks

Note: The file name returned is valid until the next call to TmpNam().

If called multiple times, it will continue to return unique temporary filenames. The location of the temporary file can be specified with the location parameter and the extension parameter can be used to specify the extension of the temporary file.

Example

The following example uses TmpNam() to get a safe temporary filename.


  local string file_name
  local mstring creport
  local mstring vlist
  local integer i

  vlist[1] = "The first line."
  vlist[2] = "The second line."
  vlist[3] = "The third line."

  file_name = TmpNam()

  call TEXT$Export( file_name, vlist )

  creport = Text$Import( file_name )

  for i = 1 to 3
       print creport[i]
  endfor

  del file_name

Output:


 The first line.
 The second line.
 The third line.

© PCI Geomatics Enterprises, Inc.®, 2026. All rights reserved.