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.
boehmi
Voice
Posts: 14 Joined: Sat Apr 11, 2009 7:55 am
Location: Germany
Post
by boehmi » Mon Apr 13, 2009 12:20 pm
Code: Select all
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
Fill
Halfop
Posts: 80 Joined: Sun Jan 18, 2009 6:08 pm
Post
by Fill » Mon Apr 13, 2009 12:47 pm
nope, that's totally wrong. First of all, you can't write this:
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:
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.
boehmi
Voice
Posts: 14 Joined: Sat Apr 11, 2009 7:55 am
Location: Germany
Post
by boehmi » Mon Apr 13, 2009 1:20 pm
erm no... proc2 is not a part of proc1
proc1 is just called 1 line before
its for a little quizbot
Code: Select all
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.
arfer
Master
Posts: 436 Joined: Fri Nov 26, 2004 8:45 pm
Location: Manchester, UK
Post
by arfer » Mon Apr 13, 2009 1:52 pm
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
Fill
Halfop
Posts: 80 Joined: Sun Jan 18, 2009 6:08 pm
Post
by Fill » Mon Apr 13, 2009 6:02 pm
in that case you must have a proc like this:
Code: Select all
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: Select all
proc1 { blah blah } {
global channel
set channel $chan
blah...
}
And then proc2 would be similar to this:
boehmi
Voice
Posts: 14 Joined: Sat Apr 11, 2009 7:55 am
Location: Germany
Post
by boehmi » Mon Apr 13, 2009 8:01 pm
Fill wrote: in that case you must have a proc like this:
Code: Select all
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
nml375
Revered One
Posts: 2860 Joined: Fri Aug 04, 2006 2:09 pm
Post
by nml375 » Thu Apr 16, 2009 3:47 pm
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