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.

hi, a snippet is needed.

Requests for complete scripts or modifications/fixes for scripts you didn't write. Response not guaranteed, and no thread bumping!
Post Reply
M
Meropie
Voice
Posts: 7
Joined: Wed Dec 19, 2007 10:02 am

hi, a snippet is needed.

Post by Meropie »

hello, im searching for a snippet to delete a line from a file.

my file looks like:
bla
bla2
bla4
meropie
egghelp

and such..

i want to delete a line, but i am searching the whole line, so it will be much easier (i think).
example:
i want to delete meropie, i will search for meropie and delete it so the file will look like:
bla
bla2
bla4
egghelp
.

thanks.
M
Maiki
Voice
Posts: 28
Joined: Sun May 20, 2007 4:58 pm

Post by Maiki »

Code: Select all

bind pub - !delete delLine

proc delLine {nick uhost hand chan arg} {
	set file [open /usr/dir r]
        set data [read -nonewline $file]
	close $file
        if {[set pos [lsearch -glob [set ldata [split $data \n]] $arg]] != -1} {
            set data [open /usr/dir w]
            puts $data [join [lreplace $ldata $pos $pos] \n]
            close $data
            putserv "PRIVMSG $chan :Deleted $arg"
        } else {
            close $data
            putserv "PRIVMSG $chan :Can not find $arg in the file"

        }

}
M
Meropie
Voice
Posts: 7
Joined: Wed Dec 19, 2007 10:02 am

Post by Meropie »

yo, thanks for the help, but error accurs:
[16:57] Tcl error [delLine]: can not find channel named "Meropie"
M
Maiki
Voice
Posts: 28
Joined: Sun May 20, 2007 4:58 pm

Post by Maiki »

Fixed.. :)
User avatar
Sir_Fz
Revered One
Posts: 3794
Joined: Sun Apr 27, 2003 3:10 pm
Location: Lebanon
Contact:

Post by Sir_Fz »

Check out user's code in this thread.
Post Reply