# jfileio.tcl

## Introduction

The jfileio.tcl library is distributed as part of the jstools package. It consists of two procedures that slightly simplify file access.

This document describes jfileio.tcl version 2001.02.10.

## Usage

### Accessing the Library

In order to use the jfileio.tcl library, it 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-2001by Jay Sekora, but may be freely redistributed under the conditions at the top of the file.

## Overview

### Procedures

`::jstools::write_file` - write given text to a file
`::jstools::read_file` - return contents of file

## ::jstools::write_file

### Usage

`::jstools::write_file` filename`` text

### Arguments

`` filename is the name of the file to open for writing
text is the string to store in filename

### Description

This procedure writes the string text to the file named file. If the file can not be opened for writing, an error will occur (invoking the Tk procedure `tkerror`(n)) The previous contents of file, if any, will be overwritten. No additional newline is appended to text.

## ::jstools::read_file

### Usage

`::jstools::read_file` file

### Arguments

`` file is the name of the file to open for reading

### Description

This procedure returns the contents of the file named file. If the file can not be opened for reading, an error will occur (invoking the Tk procedure `tkerror`(n))

## Future Directions

- A procedure to append text to a file might be useful.
- It might be nice to catch errors, figure out what caused them, and display more informative error messages, or even give the user the opportunity to create missing directories or change permissions on files sie owns.

`
`