file tempfile

Opens a new temporary file and gives its channel.

file tempfile ?VAR? ?TEMPLATE?

Description

Makes a new empty file in the working folder, opens it for reading and writing, and gives its channel. With VAR it sets VAR to the absolute path of the file. ztcl names the file tcl_tmpN and does not use TEMPLATE. The file stays after close: delete it with file delete.

Arguments

ArgumentTypeDefaultDescription
VARvariable namenoneA variable for the path of the file.
TEMPLATEpathnoneA template of the name, which ztcl does not use.

Returns

The name of the channel.

Examples

% set f [file tempfile p]
> close $f
> list [file exists $p] [file pathtype $p]
1 absolute

% set f [file tempfile]
> set r [string match file* $f]
> close $f
> set r
1

Errors

A call opens a new file. ztcl does not check the count of arguments of this subcommand (issue 688).

Differences from Tcl

Facts

Capability
file. A new interpreter does not have it until the host turns it on.
Tcl release
Tcl 9.1 and 8.6.
Since
ztcl 1.0.0-beta.1

See also