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.

"set" problem..

Help for those learning Tcl or writing their own scripts.
Post Reply
S
SaW
Voice
Posts: 8
Joined: Fri Jan 19, 2007 1:17 pm
Location: Turkey
Contact:

"set" problem..

Post by SaW »

Code: Select all

bind raw * notice tsnotice
proc tsnotice {from keyword arg} {
 if {[string match "*Client connecting on port*" $arg]} {
  if {[info exists gr]} {
   set gr [lindex $arg 9]
   utimer 10 [list set gr [lrange $gr 1 end]]
   return 0
  }
  if {[llength $gr] > "1"} {
   append gr " [lindex $arg 9]"
   utimer 10 [list set gr [lrange $gr 1 end]] 
   if {[llength $gr] >= "10"} { 
    foreach nck $gr {
     putquick "privmsg SaW: nicks : $nck"
    }
    unset $gr
   }
  }
 }
}
i want to bot msg me if 10 joins in 10 seconds, but it didnt work..
i try to see $gr each after joins from dcc with type .set gr
but the answer is:
bot: [15:40] #SaW# set gr
bot: Currently:

what is the mistake?
n
nml375
Revered One
Posts: 2860
Joined: Fri Aug 04, 2006 2:09 pm

Post by nml375 »

gr is a localspace variable (only exists within the instance of the proc when it is invoked).

Simply put, as soon as your proc exits, it will forget all about any and all variables used within it. You'll have to use globalspace variables for them to persist. either adress them as ::varname (such as "set ::gr somevalue" and "foreach nck $::gr"), or use the global-command
NML_375
S
SaW
Voice
Posts: 8
Joined: Fri Jan 19, 2007 1:17 pm
Location: Turkey
Contact:

Post by SaW »

thanks nml375.
Post Reply