# 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 4.0/4.0.

## 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@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:fileio:write` - write given text to a file

`j:fileio:read` - return contents of file

## j:fileio:write

### Usage

`j:fileio:write` 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.

## j:fileio:read

### Usage

`j:fileio:read` 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.

``