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.

else problem

Help for those learning Tcl or writing their own scripts.
Post Reply
N
NewzUK
Master
Posts: 200
Joined: Mon Nov 18, 2002 3:10 am
Location: Auckland, New Zealand
Contact:

else problem

Post by NewzUK »

Hi - I have a script to retrieve a line of data from a webpage. The line is either:
<p>and-the-info-here

or, if there is no info just:
<p>

Code: Select all

to send this into the room, the script after the socket stuff is:

    if {[string match "*<p>CENTRAL*" $line]} {
	regexp {<p>CENTRAL(.*).</p><br>} $line - central
    putserv "PRIVMSG $channel :$central"
    } else {
    putserv "PRIVMSG $channel :No Info Available"
  }
 }
}
however, it is sending both lines to the room even if there is data. I've tried putting returns in after, but then it only does the second line.

Thanks for any help?
#Newsroom - Where News & Markets Connect
http://www.inewsroom.net
#Newsroom on irc.othernet.org
m
metroid
Owner
Posts: 771
Joined: Wed Jun 16, 2004 2:46 am

Post by metroid »

Did you try common sense? ;)

Code: Select all

 if {[string match "*<p>CENTRAL*" $line]} {
  if {[regexp {<p>CENTRAL(.*).</p>} $line - central] && [string length $central] >= 1} {
    putserv "PRIVMSG $channel :$central"
  } else {
    putserv "PRIVMSG $channel :No Info Available"
  }
}
(I added the string length check to see if anything is actually in the variable)
Post Reply