I came into this a bit late, but it sounds as though you figured out how to accomplish the task. The only other improvement I have to suggest is that instead of executing a shell script to copy the new file over the old, you can use Tcl's built-in
file rename command with the
-force option (to force it to overwrite an existing file). In fact, Tcl has several built-in
file commands for doing file manipulation of that nature. Using these commands is more efficient than calling out to external programs, and they're cross-platform. Check out the
file command documentation for more information.
As an aside, let me mention another strategy for persistent storage. Using a text file as you are now is a nice, simple solution that works in many instances. It doesn't require any extensions; you can easily view it, edit it, and print it; and if the information is going to be used by another application, you might be forced to use that format. But it is inefficient for large amounts of data, especially if you need to modify only a few values out of hundreds or even thousands.
In situations where your primary goal is persistent storage, rather than data interchange, using a database like MetaKit is an excellent alternative. MetaKit is a freely available, cross-platform, open source (MIT-style licensed) database library that you can include in your own programs. It includes bindings for several languages, including Tcl. MetaKit is fast, very light-weight, reliable, and easy to use. It isn't a full-blown relational database, but has more power than a simple flat-file database.
You can get more information about MetaKit from the Tcl'ers Wiki (
on the page
The homepage for MetaKit is
And an excellent MetaKit tutorial is available from
- Ken Jones, President
Avia Training and Consulting
866-TCL-HELP (866-825-4357) US Toll free
415-643-8692 Voice
415-643-8697 Fax