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.

stopping at one line

Old posts that have not been replied to for several years.
Locked
N
NewzUK
Master
Posts: 200
Joined: Mon Nov 18, 2002 3:10 am
Location: Auckland, New Zealand
Contact:

stopping at one line

Post by NewzUK »

hi - I have this script to read a line in a file - it finds the line I want, but it reads the whole file to the channel - I only want it to read the first line with /04 in it...

proc pub:readmkw { nick uhost handle channel arg } {
set mkwf [open /home/citinews/Bots/Undernet/news/mkw2.txt r]
set data [read $mkwf]
foreach line [split $data \n] {
if {[string match */04* $line]} {
set mkw [string range $line 20 end]
if {[string match *\]* $mkw]} {
putserv "PRIVMSG #Newsroom2 :4,4 1,15 [gettime -18]ET $mkw "
} else {
putserv "PRIVMSG #Newsroom2 :4,4 4,15 [gettime -18]ET * $mkw "
}
}
}
}

thanks...
#Newsroom - Where News & Markets Connect
http://www.inewsroom.net
#Newsroom on irc.othernet.org
User avatar
user
 
Posts: 1452
Joined: Tue Mar 18, 2003 9:58 pm
Location: Norway

Post by user »

This post reminds me alot of http://forum.egghelp.org/viewtopic.php?p=33786#33786
don't double post - go read the forum rules. (regarding your problem: use 'break' to break out of the loop)
Have you ever read "The Manual"?
N
NewzUK
Master
Posts: 200
Joined: Mon Nov 18, 2002 3:10 am
Location: Auckland, New Zealand
Contact:

Post by NewzUK »

thanks - it now stops.
I'm also trying to set up a check so that it dosn't post the same headline if it was posted last - something like:

if {$mkw.last != $mkw} {
set mkw.last $mkw {

but that dosn't quite seem to work due to:
Tcl error [pub:readmkw]: syntax error in expression "$mkw.last != $mkw": extra tokens at end of expression
#Newsroom - Where News & Markets Connect
http://www.inewsroom.net
#Newsroom on irc.othernet.org
User avatar
user
 
Posts: 1452
Joined: Tue Mar 18, 2003 9:58 pm
Location: Norway

Post by user »

NewzBoy wrote:Tcl error [pub:readmkw]: syntax error in expression "$mkw.last != $mkw": extra tokens at end of expression
That's due to the "." in your variable name. If you want to use special characters in your variable names you have to enclose the name in braces so tcl knows where the name ends. Eg: ${mkw.last}
Check this page for details.
Have you ever read "The Manual"?
N
NewzUK
Master
Posts: 200
Joined: Mon Nov 18, 2002 3:10 am
Location: Auckland, New Zealand
Contact:

Post by NewzUK »

thanks - have removed the "." from it - now I get either errors for can't read $mkwlast or wrong args - should be set varname newvalue

if {$mkwlast != $mkw} {
set mkwlast $mkw {

:-?
#Newsroom - Where News & Markets Connect
http://www.inewsroom.net
#Newsroom on irc.othernet.org
N
NewzUK
Master
Posts: 200
Joined: Mon Nov 18, 2002 3:10 am
Location: Auckland, New Zealand
Contact:

Post by NewzUK »

I got around some other problems by using your gettok proc user :) now the only thing that dosn't work is the compare so it dosn't repeat same items...
#Newsroom - Where News & Markets Connect
http://www.inewsroom.net
#Newsroom on irc.othernet.org
N
NewzUK
Master
Posts: 200
Joined: Mon Nov 18, 2002 3:10 am
Location: Auckland, New Zealand
Contact:

Post by NewzUK »

anyone able to help me with this one? nothing I've tried is working...

so near but so far!

thanks again...
#Newsroom - Where News & Markets Connect
http://www.inewsroom.net
#Newsroom on irc.othernet.org
Locked