egghelp.org community Forum Index
[ egghelp.org home | forum home ]
egghelp.org community
Discussion of eggdrop bots, shell accounts and tcl scripts.
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

can't read "chan": no such variable ?

 
Post new topic   Reply to topic    egghelp.org community Forum Index -> Scripting Help
View previous topic :: View next topic  
Author Message
boehmi
Voice


Joined: 11 Apr 2009
Posts: 14
Location: Germany

PostPosted: Mon Apr 13, 2009 12:20 pm    Post subject: can't read "chan": no such variable ? Reply with quote

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
View user's profile Send private message
Fill
Halfop


Joined: 18 Jan 2009
Posts: 80

PostPosted: Mon Apr 13, 2009 12:47 pm    Post subject: Reply with quote

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
View user's profile Send private message
boehmi
Voice


Joined: 11 Apr 2009
Posts: 14
Location: Germany

PostPosted: Mon Apr 13, 2009 1:20 pm    Post subject: Reply with quote

erm no... proc2 is not a part of proc1
proc1 is just called 1 line before Wink

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
View user's profile Send private message
arfer
Master


Joined: 26 Nov 2004
Posts: 436
Location: Manchester, UK

PostPosted: Mon Apr 13, 2009 1:52 pm    Post subject: Reply with quote

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
View user's profile Send private message
Fill
Halfop


Joined: 18 Jan 2009
Posts: 80

PostPosted: Mon Apr 13, 2009 6:02 pm    Post subject: Reply with quote

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
View user's profile Send private message
boehmi
Voice


Joined: 11 Apr 2009
Posts: 14
Location: Germany

PostPosted: Mon Apr 13, 2009 8:01 pm    Post subject: Reply with quote

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
View user's profile Send private message
nml375
Revered One


Joined: 04 Aug 2006
Posts: 2857

PostPosted: Thu Apr 16, 2009 3:47 pm    Post subject: Reply with quote

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
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    egghelp.org community Forum Index -> Scripting Help All times are GMT - 4 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Forum hosting provided by Reverse.net

Powered by phpBB © 2001, 2005 phpBB Group
subGreen style by ktauber