egghelp.org community Forum Index
[ egghelp.org home | forum home ]
egghelp.org community
Discussion of eggdrop bots, shell accounts and tcl scripts.
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Weird problem with a txt-file

 
Post new topic   Reply to topic    egghelp.org community Forum Index -> Scripting Help
View previous topic :: View next topic  
Author Message
darton
Op


Joined: 21 Jan 2006
Posts: 155

PostPosted: Mon Jul 17, 2006 7:27 am    Post subject: Weird problem with a txt-file Reply with quote

Hello!
I made this script:
Code:
bind pub - !modlog atmlog
proc atmlog {nick uhost hand chan arg} {
  set fd [open $::atmfile r]
      while {![eof $fd]} {
         lappend list [gets $fd]
         set lines [split [read $fd] \n]
      }   
      close $fd           
       foreach x $lines {
         putquick "NOTICE $nick :$x"
       }       
    return 1
}

I can't see a mistake in it and an error message does not occur. Actually this script should read a textfile and give all lines with a notice to a user. So, where is the mistake?
Back to top
View user's profile Send private message
De Kus
Revered One


Joined: 15 Dec 2002
Posts: 1361
Location: Germany

PostPosted: Mon Jul 17, 2006 6:38 pm    Post subject: Reply with quote

Hint:
Code:
      while {![eof $fd]} {
         lappend list [gets $fd]
      }

and
Code:
         set lines [split [read $fd] \n]

are equivalent (except for saving into 2 diffrent vars).
btw. $lines will be an empty string if *edit* there is only one line */edit*.

Advise: why not simply
Code:
      while {![eof $fd]} {
         putquick "NOTICE $nick :[gets $fd]"
      }

_________________
De Kus
StarZ|De_Kus, De_Kus or DeKus on IRC
Copyright © 2005-2009 by De Kus - published under The MIT License
Love hurts, love strengthens...


Last edited by De Kus on Wed Jul 19, 2006 3:56 am; edited 1 time in total
Back to top
View user's profile Send private message MSN Messenger
darton
Op


Joined: 21 Jan 2006
Posts: 155

PostPosted: Tue Jul 18, 2006 7:48 am    Post subject: Reply with quote

Thank you. It works perfectly.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    egghelp.org community Forum Index -> Scripting Help All times are GMT - 4 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Forum hosting provided by Reverse.net

Powered by phpBB © 2001, 2005 phpBB Group
subGreen style by ktauber