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.

timer

Old posts that have not been replied to for several years.
Locked
N
Nexus6
Op
Posts: 114
Joined: Mon Sep 02, 2002 4:41 am
Location: Tuchola, Poland

timer

Post by Nexus6 »

I have this in proc and it works

Code: Select all

(...) putserv "MODE $chan +b ban1*!*@*
if {![info exists bans]} {set bans [timer 1 unban]} (...) 

Code: Select all

proc unban {} {
global chan 
putserv "MODE $chan -b ban1*!*@*"
}
(b0t) [23:48] TCL error in script for 'timer30':
(b0t) [23:48] can't read "chan": no such variable
Why doesn't it work? Chan is in global. It's 00:09 I won't figure it out this night, so I'd be grateful if someone helped me a bit :)
p
ppslim
Revered One
Posts: 3914
Joined: Sun Sep 23, 2001 8:00 pm
Location: Liverpool, England

Post by ppslim »

The error massge is quite meaningful in this situation.

Code: Select all

proc unban {} { 
global chan 
putserv "MODE $chan -b ban1*!*@*" 
}
Note the use of $chan.

This variable does not exists in the proc.

It must be created, or imported via 1 of three ways.

1, to explictly set the variable using th set command within the proc, but before the use of $chan.

Code: Select all

proc unban {} { 
set chan #blah
putserv "MODE $chan -b ban1*!*@*" 
}
2, to have it imported as part of passed arguments, in the proc definition

Code: Select all

proc unban {chan} { 
putserv "MODE $chan -b ban1*!*@*" 
}
3, to get the variable from a globaly defined on (as allready used in your script

Code: Select all

proc unban {} { 
global chan 
putserv "MODE $chan -b ban1*!*@*" 
}
Your code is wrong however. Allthough ti is tryign to get a global variable. The fact that this variable doesn't exist globaly, means that it will error as such.

You best bet would be to use method 2.

In the time command, you can send the channel name accross, along with calling the command.

Looking at your snippet, you could use somthing like

Code: Select all

if {![info exists bans]} {set bans [timer 1 [list unban $chan]]} (...) 
alogn with the explae code I used in method 2.
N
Nexus6
Op
Posts: 114
Joined: Mon Sep 02, 2002 4:41 am
Location: Tuchola, Poland

Post by Nexus6 »

yes, method 2 suits me the best :) Huge thanks ppslim
Locked