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.
blarre
Voice
Posts: 15 Joined: Sun Apr 28, 2002 8:00 pm
Post
by blarre » Wed Jun 12, 2002 4:51 pm
hi, i have a script that read from a text file... now its reading allt the text in the file but i whant it to only read the last line...
::: Here is the script :::
set bfile "/usr/local/eggdrop/asobiba/lan.txt"
set cmd "!nextlan"
set bwhere 1
bind pub -|- $cmd dumpfile
proc dumpfile {nick handle host chan text } {
global bfile bwhere
set foo [open $bfile r]
while { ! [eof $foo] } {
set line [gets $foo]
if {!$bwhere} {
puthelp "NOTICE $nick :$line"
} else {
puthelp "NOTICE $chan :$line"
}
}
}
thanks
//Patrik
blarre
Voice
Posts: 15 Joined: Sun Apr 28, 2002 8:00 pm
Post
by blarre » Thu Jun 13, 2002 7:43 am
please!! only need to now how i do soo the bot only read the last line in the file...
Petersen
Owner
Posts: 685 Joined: Thu Sep 27, 2001 8:00 pm
Location: Blackpool, UK
Post
by Petersen » Thu Jun 13, 2002 2:55 pm
you read through the whole file, store it in a list, and extract the last line from that list.
blarre
Voice
Posts: 15 Joined: Sun Apr 28, 2002 8:00 pm
Post
by blarre » Thu Jun 13, 2002 3:31 pm
ahh, its soo hard
...
the script line for that??
<font size=-1>[ This Message was edited by: blarre on 2002-06-13 13:31 ]</font>
ppslim
Revered One
Posts: 3914 Joined: Sun Sep 23, 2001 8:00 pm
Location: Liverpool, England
Post
by ppslim » Fri Jun 14, 2002 9:16 am
It's called laziness to not even try.
Code: Select all
set bfile "/usr/local/eggdrop/asobiba/lan.txt"
set cmd "!nextlan"
set bwhere 1
bind pub -|- $cmd dumpfile
proc dumpfile {nick handle host chan text } {
global bfile bwhere
set foo [open $bfile r]
set line [read $foo]
if {!$bwhere} {
puthelp "NOTICE $nick :[lindex $line [expr [llength $line] - 1]]"
} else {
puthelp "NOTICE $chan :[lindex $line [expr [llength $line] - 1]]"
}
catch {close $foo}
}