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.

problem with reading from txt file

Old posts that have not been replied to for several years.
Locked
m
misterys
Voice
Posts: 23
Joined: Sun Mar 30, 2003 2:43 pm

problem with reading from txt file

Post by misterys »

Hi

i have the following problem:
i want to open a mail file, and read out from line 11 till the end and put line after line in a channel...

i tried hours but this [censored] does not work :(

here is the proc:

Code: Select all

proc readmail {as df gh hj rt} { 
  global basicfile lastmail lastmailid  mailname tmpfile tmpmail 
 set foo [open $tmpmail r] 
set line [read $foo] 
foreach line [split $line "\n"]  {
set mailid2  [lindex $line [expr [llength $line] -10]]
set mailname1 [lindex $line [expr [llength $line] -1]]
if { $mailid2  == $rt } {
puthelp "privmsg #bla :$mailid2 $mailname1"
## maildatei oeffnen ##
set mailfile2 "/Maildir/cur/$mailname1:2,"
 set foo [open $mailfile2 r] 
set line [read -nonewline $foo] 
set lines [split $line "\n"] 

putserv "privmsg #bla :$lines"
}}

catch {close $foo} 
catch {close $foo} 
}


sorry for my bad english :(
g
greenbear
Owner
Posts: 733
Joined: Mon Sep 24, 2001 8:00 pm
Location: Norway

Post by greenbear »

Simply counting the lines one by one should do it...

Code: Select all

set mailfile "/home/user/mailfile.txt"
set readfrom 11

bind dcc -|- readmail dcc:readmail
proc dcc:readmail {hand idx arg} {
 global mailfile readfrom
 set counter 0
 set file [open $mailfile r]
  while {![eof $file]} {
    incr counter 1
    set line [gets $file]
    if {$counter >= $readfrom} {
      putidx $idx "$line"
    }
   }
 close $file
}
Locked