Pascal Scripting: GetTempDir

Prototype:

function GetTempDir: String;

Description:

Returns fully qualified path of the temporary directory, with trailing backslash. This does not use the Win32 function GetTempPath, due to platform differences.
Gets the temporary file path as follows:
1. The path specified by the TMP environment variable.
2. The path specified by the TEMP environment variable, if TMP is not defined or if TMP specifies a directory that does not exist.
3. The path specified by the USERPROFILE environment variable, if both TMP and TEMP are not defined or specify nonexistent directories.
4. The Windows directory, if all the above TMP, TEMP and USERPROFILE are not defined or specify nonexistent directories.