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.

vwait won't wait forever..

Old posts that have not been replied to for several years.
Locked
V
VaVaVooM
Voice
Posts: 10
Joined: Thu Feb 13, 2003 8:30 am
Location: Portugal

vwait won't wait forever..

Post by VaVaVooM »

hello there! :)

I would like to know if there is another tcl command equal (or like) the 'vwait' that will halt the tcl script that is currently running, until a variable is set.. The problem is that if i use the 'vwait' command, witch is mostly used for client/server and/or socket connections, i constantly get the error "Tcl error [pr:test]: can't wait for variable "val": would wait forever" :evil: , and this tcl is not to used in any client/server and/or socket connections...

thanks..
..for the help :D
p
ppslim
Revered One
Posts: 3914
Joined: Sun Sep 23, 2001 8:00 pm
Location: Liverpool, England

Post by ppslim »

This error happens when there are no background tasks to perform in Tcl, and not eggdrop.

Background tasks include socket based events (when registered to a command with the "filevent" command), the after command and likely a few other I can't be bothered to remember about.

What it doesn't do, is pause execution of one script, until another task has been completed.

It waits until a registered background task changes the value, to the variable passed to vwait.

Thus, if no background tasks are registered, it will simply wait forever, as there is nothing to.

Another thing the vwait command doesn't do, is continue with the rest of life. It pauses at the current point in code, and only performs Tcl registered events, and nothing else (this includes no processing any eggdrop stuff).

THere are ways to pause the action, while not blocking, or using the Tcl event system. However, there is real example that can be shown.

Maybe if we knew a little more of what you are trying to do, we can help.
V
VaVaVooM
Voice
Posts: 10
Joined: Thu Feb 13, 2003 8:30 am
Location: Portugal

Post by VaVaVooM »

This is the tcl.. self explanatory.. i think :)

proc vald {nick} {putserv "whois $nick"}
bind raw - 311 val:user
proc val:user {from keyword text} {
global val
{...}
set val 1
return 0
}

bind pub - !val nfo
proc nfo {nick uhost hand chan text} {
global val
set val 0
vald $nick
vwait val
{...}
}
p
ppslim
Revered One
Posts: 3914
Joined: Sun Sep 23, 2001 8:00 pm
Location: Liverpool, England

Post by ppslim »

This doesn't work, for the reasons stated.

Eggdrop Tcl scripts, are not background tasks, or at least not in the Tcl scope of background tasks.

vwait is designed to block the main loop, until the data required to continue is processed. The problem with eggdrop, the the RAW bind won't be triggered until the main lopp has cycled at least once.

You will have to store any data that is needed to send information elewhere, in global memory. Once you have any RAW retuened data needed, you can use this stored information to forward other details on.

IE, it's the reverse of what you are currently using.

Instead of freezing the current proc until you have the data needed. You freeze the data needed (store it in a variable) and use it once you have the rest of the info.

Here is a fake example.

Code: Select all

bind pub - "!test" tester1
proc tester1 {nick uh hand chan arg} {
  global SendTo
  set SendTo [lindex [split $arg] 0]
  putserv "COMMAND [lindex [split $arg] 1]"
}
bind RAW - "123" raw:test
proc raw:test {fro  key arg} {
  global SendTo
  putserv "PRIVMSG $SendTo: [lindex [split $arg] 0]"
}
V
VaVaVooM
Voice
Posts: 10
Joined: Thu Feb 13, 2003 8:30 am
Location: Portugal

Post by VaVaVooM »

thanks ppslim :D
i caught the idea..
Locked