| View previous topic :: View next topic |
| Author |
Message |
boehmi Voice
Joined: 11 Apr 2009 Posts: 14 Location: Germany
|
Posted: Mon Apr 13, 2009 12:20 pm Post subject: can't read "chan": no such variable ? |
|
|
| Code: | proc1 $chan
utimer 60 { proc2 $chan }
|
proc1 works correct... but the proc2-call within the {} throws the error can't read "chan": no such variable
Shouldn't $chan be valid inside a new {} block, just like in a do..while {} loop?
What is the problem?
Thanks for your help |
|
| Back to top |
|
 |
Fill Halfop
Joined: 18 Jan 2009 Posts: 80
|
Posted: Mon Apr 13, 2009 12:47 pm Post subject: |
|
|
nope, that's totally wrong. First of all, you can't write this:
| Code: |
utimer 60 { proc 2 $chan }
|
Utimer commands are normally used inside brackets [], and if you want to execute a comand after 60 seconds (1 minute) you'll have to do something like this:
| Code: |
utimer 60 [list proc2 $chan]
|
If you get no such variable with $chan, it's because you didn't load that variable on proc1. When is proc1 called?
Show me the whole script so I can understand better how we're going to load up $chan. |
|
| Back to top |
|
 |
boehmi Voice
Joined: 11 Apr 2009 Posts: 14 Location: Germany
|
Posted: Mon Apr 13, 2009 1:20 pm Post subject: |
|
|
erm no... proc2 is not a part of proc1
proc1 is just called 1 line before
its for a little quizbot
| Code: |
proc quiz_start { nick uhost hand chan args } {
global quiz_status
set quiz_status "started"
sendmsg "PRIVMSG $chan :Quiz startet..."
putlog "test"
ask_question $chan
utimer 60 [list give_answer $chan]
}
|
if i use utimer 60 [list proc2 $chan] he just does nothing :/
not even errors
Last edited by boehmi on Mon Apr 13, 2009 8:04 pm; edited 1 time in total |
|
| Back to top |
|
 |
arfer Master

Joined: 26 Nov 2004 Posts: 436 Location: Manchester, UK
|
Posted: Mon Apr 13, 2009 1:52 pm Post subject: |
|
|
Either there is no proc called give_answer, or the proc give_answer doesn't take a single argument (in this case $chan). _________________ I must have had nothing to do |
|
| Back to top |
|
 |
Fill Halfop
Joined: 18 Jan 2009 Posts: 80
|
Posted: Mon Apr 13, 2009 6:02 pm Post subject: |
|
|
in that case you must have a proc like this:
| Code: |
proc give_answer { chan } {
blah blah blah...
}
|
proc2 must take the chan argument as shown above. try it like that.
or...
if you don't want proc2 to have any arguments (proc2 {} { blah }), you can make $chan a global variable on proc1:
| Code: |
proc1 { blah blah } {
global channel
set channel $chan
blah...
}
|
And then proc2 would be similar to this:
| Code: |
proc2 {} {
global channel
blah
}
|
|
|
| Back to top |
|
 |
boehmi Voice
Joined: 11 Apr 2009 Posts: 14 Location: Germany
|
Posted: Mon Apr 13, 2009 8:01 pm Post subject: |
|
|
| Fill wrote: | in that case you must have a proc like this:
| Code: |
proc give_answer { chan } {
blah blah blah...
}
|
proc2 must take the chan argument as shown above. try it like that. |
yeah i did it like that... but the problem of my first post were the {} around the call.
However now it's working with [list ..]
Thank you very much |
|
| Back to top |
|
 |
nml375 Revered One
Joined: 04 Aug 2006 Posts: 2857
|
Posted: Thu Apr 16, 2009 3:47 pm Post subject: |
|
|
A word of advice for the future, avoid using "args" as an argument name. It'll "screw" things up for you if you are not aware of it's special properties.
If you'd like a more technical explanation how the timer/utimer command works, and why you should use the [list ...] approach, see this thread _________________ NML_375, idling at #eggdrop@IrcNET |
|
| Back to top |
|
 |
|