|
| |
.GetTempFile
Description
- Calculates and displays a random temporary file name
- Saves the value in #TempFile
- Saves the previous value of #TempFile (if it exists) in #Previous_#TempFile
- Sets errorlevel based on the result
Syntax
Parameters and Switches
Errorlevels and Output Variables
|
Display to
STDOUT |
|
Value of
#TempFile |
|
Error
Level |
|
Description of
Result |
|
complete
filespec
of the
temporary
file |
|
complete
filespec
of the
temporary
file |
|
0 |
|
A temporary file with
Read-Write access was obtained |
|
n/a |
|
n/a |
|
1 |
|
No Read-Write access could
be found |
Examples, Notes and Instructions
- #TempFile uses the equivalent "short names" for the file and path whenever possible.
- The temporary file name is constructed in five parts:
| ~~ |
|
literal prefix, always two "~"
characters |
| %~sn0 |
|
Expands to the short file name of the
script that is running when .GetTempFile is executed. If this value is unavailable, the literal characters "%~sn0" will be part of the temporary file name. This usually
occurs because .GetTempFile has been run from a command prompt. The file name is still valid with the "%~sn0" characters in it and can be used normally. |
| - |
|
literal "-"
character, separates the short filename from the "random" number |
| nnnnnnnn |
|
The "random" part of the file name,
loosely based on the current Precise Log Time (see #LogTimeP). While this is
not a truly "random" number, it is random enough to allow multiple simultaneous runs of the same script, on the same machine, using the same temp folder, without conflicts. |
| .txt |
|
the literal ".txt" extension
allows easy viewing and editing of the file with a double-click (as opposed to ".tmp") |
- When retrieving one or more temporary files for use in a script, it is best to execute %.GetTempFile% in the main body of the script and
not within any subroutine. This will help to avoid the literal characters "%~sn0" as part of the temporary file name.
- Output is displayed to STDOUT
- To suppress console display, use
%.GetTempFile% %.Quiet%
{errorlevel and output variable(s) will still be available}
Related .Mount/\Commands, #Constants,
$Functions, :Procedures
|
K
E
Y |
Common Commands |
INTERNAL |
External |
/SWITCH |
Parameter |
Help text |
AddonTool |
|
Mounted Commands |
.Mount/\Command |
CmdShorthand |
#Constant |
$FUNCTION |
:Procedure |
!GuardNote |
|
Operating Systems |
NT/2K/XP/K3 |
NT Only |
NT/2K |
2K Only |
2K/XP |
XP Only |
XP/K3 |
K3 Only |
2K/XP/K3 |
|