| View previous topic :: View next topic |
| Author |
Message |
darton Op
Joined: 21 Jan 2006 Posts: 155
|
Posted: Mon Jul 17, 2006 7:27 am Post subject: Weird problem with a txt-file |
|
|
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 |
|
 |
De Kus Revered One

Joined: 15 Dec 2002 Posts: 1361 Location: Germany
|
Posted: Mon Jul 17, 2006 6:38 pm Post subject: |
|
|
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 |
|
 |
darton Op
Joined: 21 Jan 2006 Posts: 155
|
Posted: Tue Jul 18, 2006 7:48 am Post subject: |
|
|
| Thank you. It works perfectly. |
|
| Back to top |
|
 |
|