vl-filename-mktemp (AutoLISP)

Calculates a unique file name to be used for a temporary file

Supported Platforms: Windows and Mac OS

Signature

(vl-filename-mktemp [pattern directory extension])
pattern

Type: String

File name pattern; if nil or absent, vl-filename-mktemp uses “$VL~~”.

directory

Type: String

Directory for temporary files; if nil or absent, vl-filename-mktemp chooses a directory in the following order:

  • The directory specified in pattern, if any.
  • The directory specified in the TMP environment variable.
  • The directory specified in the TEMP environment variable.
  • The current directory.
extension

Type: String

Extension to be assigned to the file; if nil or absent, vl-filename-mktemp uses the extension part of pattern (which may be an empty string).

Return Values

Type: String

A textual value containing a file name, in the following format:

directory\base<XXX><.extension>

where:

base is up to 5 characters, taken from pattern

XXX is a 3-character unique combination

All file names generated by vl-filename-mktemp during a session are deleted when you exit the application.

Release Information

History

Examples

Windows
(vl-filename-mktemp)
"C:\\TMP\\$VL~~004"

(vl-filename-mktemp "myapp.del")
"C:\\TMP\\MYAPP005.DEL"

(vl-filename-mktemp "c:\\acadwin\\myapp.del")
"C:\\ACADWIN\\MYAPP006.DEL"

(vl-filename-mktemp "c:\\acadwin\\myapp.del")
"C:\\ACADWIN\\MYAPP007.DEL"

(vl-filename-mktemp "myapp" "c:\\acadwin")
"C:\\ACADWIN\\MYAPP008"

(vl-filename-mktemp "myapp" "c:\\acadwin" ".del")
"C:\\ACADWIN\\MYAPP00A.DEL"
Mac OS
(vl-filename-mktemp)
"/documents/$VL~~001"

(vl-filename-mktemp "myapp.del")
"/documents/MYAPP002.DEL"

(vl-filename-mktemp "/myutilities/temp/myapp.del")
"/myutilities/temp/MYAPP003.DEL"

(vl-filename-mktemp "/myutilities/temp/myapp.del")
"/myutilities/temp/MYAPP004.DEL"

(vl-filename-mktemp "myapp" /myutilities/temp")
"/myutilities/temp/MYAPP005"

(vl-filename-mktemp "myapp" "/myutilities/temp" ".del")
"/myutilities/temp/MYAPP006.DEL"