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 for those learning Tcl or writing their own scripts.
-
darton
- Op
- Posts: 155
- Joined: Sat Jan 21, 2006 11:03 am
Post
by darton »
Hello!
If I want to display everything of a textfile in a channel I use this script.
Code: Select all
proc foo {nick uhost hand chan arg} {
set fd [open $::foofile r]
while {![eof $fd]} {
putquick "PRIVMSG $chan :[gets $fd]"
}
close $fd
}
The output looks like this:
(@Bot) bla
(@Bot) blabla
(@Bot) blablabla
But I want that everything is displayed in just one line. So it must look like this:
(@Bot) bla blabla blablabla
What do I have to change in my script?
-
nml375
- Revered One
- Posts: 2860
- Joined: Fri Aug 04, 2006 2:09 pm
Post
by nml375 »
you could try "read" (reads as much as possible from the file), and then use string map (to change newlines into spaces)
Code: Select all
proc foo {nick host hand chan text} {
set fd [open $::foofile r]
set data [read $fd]
puthelp "PRIVMSG $chan :[string map {"\n" " " "\r" " "}]"
close $fd
}
I think something like that should do the trick...
NML_375
-
darton
- Op
- Posts: 155
- Joined: Sat Jan 21, 2006 11:03 am
Post
by darton »
Thank you. It works.