# jtclutils.tcl

## Introduction

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.

## Usage

### Accessing the Library

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.

## Credits and Copyright

### Author

Jay Sekora

`js@calumet.org`

`http://shore.net/~js/`

### Copyright

The library is copyright © 1992-1995 by Jay Sekora, but may be freely redistributed under the conditions at the top of the file.

## Overview

### Procedures

`j:default` - specify a default value for a variable, creating it if necessary

## j:default

### Usage

`j:default` var`` value

### Arguments

var - variable to create if necessary

value - default value to assign to var if it's not already set

### Examples

`global SAVE_BEFORE_QUITTING

if [j:default SAVE_BEFORE_QUITTING 1] {save}

j:default filename [glob -nocomplain ~/.foo]

save_to_file $filename

`

### Description

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.)

``