Difference between revisions of "TMPNAM()"
Yvonne.milne (Talk | contribs) |
|||
(6 intermediate revisions by 3 users not shown) | |||
Line 1: | Line 1: | ||
==Purpose== | ==Purpose== | ||
− | Function to return temporary | + | Function to return a temporary filename |
− | + | ||
==Syntax== | ==Syntax== | ||
− | TMPNAM( [<expC1> [,<expC2>] | + | TMPNAM([<expC1> [,<expC2>]]) |
+ | TMPNAM(<expC2>) | ||
+ | |||
+ | TMPNAM(<expL>) | ||
==See Also== | ==See Also== | ||
− | + | [[GETENV()]], [[GETGID()]], [[GETUID()]], [[GETPID()]], [[RAND()]], [[SET TMPDIR]], [[SET TMPNAMPATH]], [[SYS()]] | |
− | + | ||
==Description== | ==Description== | ||
The TMPNAM() function creates a temporary file and returns a character string containing the filename. By default, filenames returned by the TMPNAM() function have the extension ".tmp". The TMPNAM() function is particularly useful in multi-user applications where a unique temporary file can be created for each user process. The optional argument <expC1> specifies a directory where the temporary filename will created. The optional argument <expC2> specifies a file extension to use other than the default one of '.tmp'. | The TMPNAM() function creates a temporary file and returns a character string containing the filename. By default, filenames returned by the TMPNAM() function have the extension ".tmp". The TMPNAM() function is particularly useful in multi-user applications where a unique temporary file can be created for each user process. The optional argument <expC1> specifies a directory where the temporary filename will created. The optional argument <expC2> specifies a file extension to use other than the default one of '.tmp'. | ||
− | Note: if <expC1> is not specified and [[SET TMPNAMPATH]] is ON (default), the file will be created in the [[ | + | Note: if <expC1> is not specified and [[SET TMPNAMPATH]] is ON (default), the file will be created in the [[TMPDIR()]] directory and the filename returned will include the full path. If SET TMPNAMPATH is OFF, only the filename will be returned and the file will be created in the current directory. This behavior can also be achieved using the optional logical parameter <expL>. If <expL> is .F. (False), only the filename will be returned, if .T. (True), the full path will be returned. |
− | + | ||
==Example== | ==Example== | ||
<code lang="recital"> | <code lang="recital"> | ||
− | + | // Filename with '.tmp' extension and TMPDIR() path | |
− | + | cTempFile = tmpnam() | |
− | + | // Filename with '.txt' extension and specified path | |
− | + | cTempFile = tmpnam("C:\temp\", ".txt") | |
+ | // Filename with '.txt' extension and TMPDIR() path | ||
+ | cTempFile = tmpnam(".txt") | ||
+ | // Filename with '.tmp' extension and no path | ||
+ | cTempFile = tmpnam(.F.) | ||
</code> | </code> | ||
− | |||
− | |||
− | |||
[[Category:Documentation]] | [[Category:Documentation]] | ||
[[Category:Functions]] | [[Category:Functions]] | ||
+ | [[Category:Lianja VFP Extensions]] | ||
+ | [[Category:VFP Function Extensions]] |
Latest revision as of 05:25, 26 May 2017
Contents
Purpose
Function to return a temporary filename
Syntax
TMPNAM([<expC1> [,<expC2>]])
TMPNAM(<expC2>)
TMPNAM(<expL>)
See Also
GETENV(), GETGID(), GETUID(), GETPID(), RAND(), SET TMPDIR, SET TMPNAMPATH, SYS()
Description
The TMPNAM() function creates a temporary file and returns a character string containing the filename. By default, filenames returned by the TMPNAM() function have the extension ".tmp". The TMPNAM() function is particularly useful in multi-user applications where a unique temporary file can be created for each user process. The optional argument <expC1> specifies a directory where the temporary filename will created. The optional argument <expC2> specifies a file extension to use other than the default one of '.tmp'.
Note: if <expC1> is not specified and SET TMPNAMPATH is ON (default), the file will be created in the TMPDIR() directory and the filename returned will include the full path. If SET TMPNAMPATH is OFF, only the filename will be returned and the file will be created in the current directory. This behavior can also be achieved using the optional logical parameter <expL>. If <expL> is .F. (False), only the filename will be returned, if .T. (True), the full path will be returned.
Example
// Filename with '.tmp' extension and TMPDIR() path cTempFile = tmpnam() // Filename with '.txt' extension and specified path cTempFile = tmpnam("C:\temp\", ".txt") // Filename with '.txt' extension and TMPDIR() path cTempFile = tmpnam(".txt") // Filename with '.tmp' extension and no path cTempFile = tmpnam(.F.)