Product Site

8.62. SysTempFileName

Returns a unique name for a file or directory that does not currently exist. If an error occurs or SysTempFileName cannot create a unique name from the template, it returns a null string. SysTempFileName is useful when a program requires a temporary file.

Parameters:
template

The template is a valid file or directory specification including a path, with between one and nine filler characters.

SysTempFileName generates filler character replacements with a random number algorithm. If the resulting file or directory already exists, SysTempFileName increments the replacement value until all possibilities have been exhausted.

The file path and name of the template can be of any length. If the template contains no or more than nine filler characters, SysTempFileName returns a null string. Filler characters are allowed both in the path and the name part of template. The unique name is created solely by substituting a random numeric digit for each filler character. If there is a directory name part of the template in addition to the file name part, and the directory name part contains a non-existent directory, the function will succeed. However, the temporary file will not be writable unless the user first creates the non-existent directory, or directories.
filler

The filler character used in template. SysTempFileName replaces each filler character in template with a random numeric digit. The resulting string represents a file or directory that does not exist. The default filler character is ?.

See also File method temporaryPath (Class Method).
Example 8.44. RexxUtil — SysTempFileName
say SysTempFileName("file???")                -- (e. g.) C:\Users\User1\file392
                                              -- (e. g.) /home/user1/file384
say SysTempFileName("/temp/myfile.***", "*")  -- (e. g.) C:\temp\myfile.938
                                              -- (e. g.) /temp/myfile.341