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.

variables, globals?

Help for those learning Tcl or writing their own scripts.
Post Reply
m
matey
Voice
Posts: 1
Joined: Tue Sep 19, 2006 10:42 pm

variables, globals?

Post by matey »

(Sorry for the poor subject, but i couldnt find a better one)

The following script listens on a socket and sends the result into an IRC channel.
It works.
I want it to not send identical messages in a row. Therefore I'd like to store the $msg before it is send out to the channel, and check the next time, before a message is sent, if the stored text is identical to $msg.
If so, the script should interrupt and wait for the next piece of incoming data.

My question basically is: What kind of variable do i need to store the message? a global, or var? I tried to set up a simple loop all night long but it just didnt work.

Here's the code:

Code: Select all

 socket -server blubb 4711



proc blubb {cid addr port} { 
	fconfigure $cid -buffering line -blocking 0;
	fileevent $cid readable "bbb $cid"
}


proc bbb {cid} {

	if {[gets $cid msg] == ""} {
		putserv "PRIVMSG #grill-bill :empty"
		close $cid; return
	}

	putserv "PRIVMSG #grill-bill :$msg" 
	close $cid; return
}
[/code]
Post Reply