This is the new home of the egghelp.org community forum.
All data has been migrated (including user logins/passwords) to a new phpBB version.


For more information, see this announcement post. Click the X in the top right-corner of this box to dismiss this message.

How to manage a simple database (text file)

Help for those learning Tcl or writing their own scripts.
Post Reply
s
skgsergio
Voice
Posts: 2
Joined: Sun Oct 10, 2010 7:55 pm

How to manage a simple database (text file)

Post by skgsergio »

I'm trying to do a simple database with this schema using text file:

Code: Select all

Nick1 Number Number
Nick2 Number Number
Nick3 Number Number
...
How to use data is simple and how to search or insert a new line is easy.

But I don't know how to do things like modify an entry (or delete but I don't need delete for my script).

Anyone can help me?
w
willyw
Revered One
Posts: 1209
Joined: Thu Jan 15, 2009 12:55 am

Re: How to manage a simple database (text file)

Post by willyw »

Just thinking about it ( I haven't experimented and tried it) ... could you read your text file into a list?
( http://forum.egghelp.org/viewtopic.php?t=6885 )

Then, manipulate the list... searching, replacing, etc.
( ex: http://www.tcl.tk/man/tcl8.5/TclCmd/lreplace.htm
and
http://www.tcl.tk/man/tcl8.5/TclCmd/lsearch.htm )

When done, write the list back to text file, overwriting the original file.

Is that viable?


p.s. There is a high probability that I've read about doing it this way, somewhere in the past. Most likely, that would be this forum. In other words, it might be a good idea to try some searches here... you might find it described in more detail. :)
s
skgsergio
Voice
Posts: 2
Joined: Sun Oct 10, 2010 7:55 pm

Post by skgsergio »

I read and saw some scripts using it but I didn't know if it's a good way but I will test it.
About searching... well I searched by "text file database" an didn't found that post.

Thx for all.
Post Reply