The jtclutils.tcl library is distributed as part of the jstools package. It will consist of general Tcl convenience and utility procedures that do not require Tk. Currently it only contains one procedure.
This document describes jtclutils.tcl version 4.0/4.0.
In order to use the jtclutils.tcl library, it (and any other libraries it depends on) must be in your Tcl auto_path, described in tclvars(n). Information about how to arrange that, and other conventions common to the jstools libraries, is in the Usage section of The jstools Libraries.
Jay Sekora
js@calumet.org
http://shore.net/~js/
The library is copyright © 1992-1995 by Jay Sekora, but may be freely redistributed under the conditions at the top of the file.
j:default - specify a default value for a variable, creating it if necessary
j:default var value
var - variable to create if necessary
value - default value to assign to var if it's not already set
global SAVE_BEFORE_QUITTING
if [j:default SAVE_BEFORE_QUITTING 1] {save}
j:default filename [glob -nocomplain ~/.foo]
save_to_file $filename
If var does not already exist (in the context of the calling procedure), this procedure creates it and assigns value to it. If var already exists, its value will not be changed.
In either case, the current value of var in the calling procedure's context is returned, as with the Tcl set(n) command.
This is useful for working variables that may or may not have been set already, e.g., after reading a user's configuration file.
(For assigning default values to arguments to a procedure, see j:parse_args in jparseargs.tcl.)