"[JuanCarlos] <juancarlos> <3780-2292-1521>"
from the lines below.
[Chaoszer14] <chaoszero14> <3350-8023-6356>
[Jjoiu] <jjoiu> <0687-8131-8871>
[JuanCarlos] <juancarlos> <3780-2292-5121>
[Lostfan2420] <lostfan2420> <4639-3128-6539>
[Shade] <shade> <5412-2685-7596>
------------
I am having quite a bit of trouble figuring out how to a remove a specified line from a text file. And if you can, could you make so that the person could only remove the line "[JuanCarlos] <juancarlos> <3780-2292-1521>" if there name was juancarlos.
When I tried to make a proc to do this myself, it ended up deleting my whole txt file. The code I used is below. Maybe I did something wrong in my code, or maybe I just need a new code in general. (everytime it would say user not found when I typed !delmpht juancarlos, and then I checked the user to file to clarify, and the whole file was erased.)
Code: Select all
proc deleteuser {nick uhost hand chan arg} {
global mphtfile
if {$arg != ""} {
set gamer [lindex [split $arg] 0]
set fd [open $::mphtfile r+]
while {![eof $fd]} {
lappend list [gets $fd]
}
close $fd
set fd [open $::mphtfile w+]
if {[set le [lsearch -exact $list $gamer]] != -1} {
puts -nonewline $fd [join [lreplace $list $le $le] \n]
} else {
putquick "PRIVMSG $chan :That user was not found."
}
close $fd
}
}