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.
Old posts that have not been replied to for several years.
-
snow-ball
- Voice
- Posts: 22
- Joined: Fri Oct 26, 2001 8:00 pm
Post
by snow-ball »
Hi
Any other faster method to update a file?
For example i have a file to store some information like names.
name1 xxx xxx
name2 yyy yyy
name3 zzz zzz
If i want to update the name3
I use this code:
set name [lindex $text 1]
set update [lrange $text 2 end]
file copy names.dat names.back
set back [open names.back r]
set file [open names.dat w]
while {![eof $back]} {
set line [gets $file]
if {[lindex $line 0] == $name]} {
puts $file "$names [list $update]"
continue
}
puts $file $line
}
close $file; close $back
file delete names.back
Tks
-
stdragon
- Owner
- Posts: 959
- Joined: Sun Sep 23, 2001 8:00 pm
-
Contact:
Post
by stdragon »
What do you mean by faster? Do you mean less code or less cpu?
With your example, name3 was the last name. Do you always want to update only the last name?
-
snow-ball
- Voice
- Posts: 22
- Joined: Fri Oct 26, 2001 8:00 pm
Post
by snow-ball »
stdragon wrote:What do you mean by faster? Do you mean less code or less cpu?
With your example, name3 was the last name. Do you always want to update only the last name?
Hi
My current data base have a little more of 700 lines.
Is any other way to update the information more quickly ?
Or my current code do a good job?
tks