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.
Help for those learning Tcl or writing their own scripts.
LethPhaos
Voice
Posts: 7 Joined: Wed Apr 18, 2007 2:04 pm
Post
by LethPhaos » Sat Apr 21, 2007 1:50 pm
Hi all,
I get the following error message:
Code: Select all
Tcl error [pub:command]: can't read "channels(output)": no such variable
when I type !command while i'm in channel #output, how can I solve this problem?
Thanks in advance!
Code: Select all
set channels(output) "#output #output2"
set channels(output) [ split $channels(output) ]
bind pub -|- "!command" pub:command
proc pub:command { nick uhost hand chan args } {
if { [ validchan $chan ] } {
putquick "privmsg $chan :you called?"
}
}
proc validchan { chan } {
foreach c $channels(output) {
if { $chan == $c } { return 1 }
else { return 0 }
}
}
Last edited by
LethPhaos on Sun Apr 22, 2007 3:54 am, edited 2 times in total.
Sir_Fz
Revered One
Posts: 3794 Joined: Sun Apr 27, 2003 3:10 pm
Location: Lebanon
Contact:
Post
by Sir_Fz » Sat Apr 21, 2007 2:12 pm
delete
Code: Select all
proc validchan { chan } {
foreach c $channels(output) {
if { $chan == $c } { return 1 }
else { return 0 }
}
}
I don't see the use of this check (validchan) anyway, the bot is already on it when it saw the request.
Edit: After reading your post again, I noticed that the error you posted has nothing to do with the code you posted.
However, I suggest you change the name of your proc [validchan] since that is an Eggdrop Tcl command and may cause problems with other scripts.
LethPhaos
Voice
Posts: 7 Joined: Wed Apr 18, 2007 2:04 pm
Post
by LethPhaos » Sat Apr 21, 2007 2:22 pm
i'll change the name of the proc to checkchan
i'm not removing the proc because the bot doesn't have to react on the command on every channel it is in, only on channels specified in the var
what do you think is causing the problem?
thanks for your help!
Sir_Fz
Revered One
Posts: 3794 Joined: Sun Apr 27, 2003 3:10 pm
Location: Lebanon
Contact:
Post
by Sir_Fz » Sat Apr 21, 2007 2:38 pm
Tcl error [pub:command]: can't read "prechan(output)": no such variable
In the code you've posted, there's no
prechan array at all. I guess you've changed the names of the variables; your 'channels' array is not global in the validchan proc, so use $::channels(output) instead.
LethPhaos
Voice
Posts: 7 Joined: Wed Apr 18, 2007 2:04 pm
Post
by LethPhaos » Sat Apr 21, 2007 3:11 pm
oops, indeed forgot to replace one var name, fixed
edit: okay, it's workig now, due to your hint of adding the ::
but what does that do exactly? :p
Sir_Fz
Revered One
Posts: 3794 Joined: Sun Apr 27, 2003 3:10 pm
Location: Lebanon
Contact:
Post
by Sir_Fz » Sat Apr 21, 2007 7:37 pm
You want to use the global variable inside the procedure but you're using it as a local variable (belonging to the proc's level), using :: indicates that the variable is in the global namespace. You can add 'global channels' line in your proc and normally use $channels(output) instead.
LethPhaos
Voice
Posts: 7 Joined: Wed Apr 18, 2007 2:04 pm
Post
by LethPhaos » Sun Apr 22, 2007 3:53 am
Thanks a lot!