# 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.1/4.4.

## 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@aq.org`
`http://www.aq.org/~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:mkdir` - create a directory and its parent directories, 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.)

## j:mkdir

### Usage

`j:mkdir` dir

### Arguments

dir - directory to make

### Description

If dir does not already exist, this procedure attempts to create it (and all its parent directories). If the directory can't be created (e.g. because the user doesn't have appropriate permission or dir already exists and is not a directory), an error is produced.
`
`