| View previous topic :: View next topic |
| Author |
Message |
LethPhaos Voice
Joined: 18 Apr 2007 Posts: 7
|
Posted: Sat Apr 21, 2007 1:50 pm Post subject: [solved] error regarding a variable |
|
|
Hi all,
I get the following error message:
| Code: | | 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: | 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 |
|
| Back to top |
|
 |
Sir_Fz Revered One

Joined: 27 Apr 2003 Posts: 3793 Location: Lebanon
|
Posted: Sat Apr 21, 2007 2:12 pm Post subject: |
|
|
delete
| Code: | 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. _________________ Follow me on GitHub
- Opposing
Public Tcl scripts |
|
| Back to top |
|
 |
LethPhaos Voice
Joined: 18 Apr 2007 Posts: 7
|
Posted: Sat Apr 21, 2007 2:22 pm Post subject: |
|
|
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! |
|
| Back to top |
|
 |
Sir_Fz Revered One

Joined: 27 Apr 2003 Posts: 3793 Location: Lebanon
|
Posted: Sat Apr 21, 2007 2:38 pm Post subject: |
|
|
| Quote: | | 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. _________________ Follow me on GitHub
- Opposing
Public Tcl scripts |
|
| Back to top |
|
 |
LethPhaos Voice
Joined: 18 Apr 2007 Posts: 7
|
Posted: Sat Apr 21, 2007 3:11 pm Post subject: |
|
|
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 |
|
| Back to top |
|
 |
Sir_Fz Revered One

Joined: 27 Apr 2003 Posts: 3793 Location: Lebanon
|
Posted: Sat Apr 21, 2007 7:37 pm Post subject: |
|
|
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. _________________ Follow me on GitHub
- Opposing
Public Tcl scripts |
|
| Back to top |
|
 |
LethPhaos Voice
Joined: 18 Apr 2007 Posts: 7
|
Posted: Sun Apr 22, 2007 3:53 am Post subject: |
|
|
| Thanks a lot! |
|
| Back to top |
|
 |
|