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.

help me whit a litle question

Old posts that have not been replied to for several years.
Locked
b
blarre
Voice
Posts: 15
Joined: Sun Apr 28, 2002 8:00 pm

Post by blarre »

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
b
blarre
Voice
Posts: 15
Joined: Sun Apr 28, 2002 8:00 pm

Post by blarre »

please!! only need to now how i do soo the bot only read the last line in the file...
P
Petersen
Owner
Posts: 685
Joined: Thu Sep 27, 2001 8:00 pm
Location: Blackpool, UK

Post by Petersen »

you read through the whole file, store it in a list, and extract the last line from that list.
b
blarre
Voice
Posts: 15
Joined: Sun Apr 28, 2002 8:00 pm

Post by blarre »

ahh, its soo hard :razz:...
the script line for that??

<font size=-1>[ This Message was edited by: blarre on 2002-06-13 13:31 ]</font>
p
ppslim
Revered One
Posts: 3914
Joined: Sun Sep 23, 2001 8:00 pm
Location: Liverpool, England

Post by ppslim »

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}
}
Locked