On Sun, 22 Aug 1999, [EMAIL PROTECTED] wrote:

> I am writing a small client tracking app in which I am using a
> small text database using the | symbol as a field delimiter.    I am used to
> using a berkly style database and perl for such file operations, however, I
> would like to see clear text in the data file if possible.  My question is
> currently I am just grabbing the file sending all the info into an array and
> then rewriting the file in the order and with the changes I am desiring.  I
> find this to be risky for record deletion as well as other things and I am
> wandering if someone could offer a better way.  I would not mind to use a
> berkley style database but do not know how or even if possible Tcl.  

I don't know what a berkley style database is. There are a few database
extentions for Tcl. 

You say you are "sending all the info into an array". Do you mean a list?

I would be inclined to

- read the file into a variable, for example "dbdata".
- split it into a list of records:  set dbrecs [split $dbdata \n]
- you can split records into fields with [split $dbrec |]
  (where dbrec is [lindex $dbrecs 0], for example)

You can insert, delete, replace, search and sort (on fields!) with the
various Tcl list commands.

You could be a bit safe and rename your current database to db.BAK before
writing out the new file, and put the .BAK file back into place if there
is a write error, etc.

...RickM...

---------------------------------------------------------------------------
To unsubscribe from the Visual Tcl mailing list, please send a message
to [EMAIL PROTECTED] with "unsubscribe vtcl [EMAIL PROTECTED]" in the
message body (where [EMAIL PROTECTED] is your e-mail address).

Reply via email to