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.

Two TCL Problems

Old posts that have not been replied to for several years.
Locked
G
Guest

Post by Guest »

First one:
'after ms proc' command seems to run inside command instantly and not wait ms.
http://www.scriptics.com/man/tcl8.4/TclCmd/after.htm

Second one:
'fileevent channel writable proc'
seems to run every second instead of intended as soon as channel is writable.
p
ppslim
Revered One
Posts: 3914
Joined: Sun Sep 23, 2001 8:00 pm
Location: Liverpool, England

Post by ppslim »

These are both Tcl issues, as eggdrop does not affect there usage in any way.

Once every event loop inside eggdrop, Tcl_DoOneEvent is called. Tcl then checks to make sure that it is upto date with it's "after" and "fileevent" commands.

Eggdrop does not have access to the information provided to Tcl in the "fileevent" or "after" commands, as it is Tcl's responcibility.

What are you specifying as "ms" in the after command, and why do you actualy need to work with then units of time? It is far more simpler to use eggdrops "utimer" to call after 1 second.

Did you ever consider that the fileevent is calling the proc, because the channel is writable, and not because there is a glitch.
G
Guest

Post by Guest »

ms is milliseconds, any number there doesn't make any difference when its used only in eggdrop, and as for why I need these 2 commands, its for file sending over socket. I've used all these commands in a raw shell script with no problems, so I can only conclude eggdrop is the problem. Ohh and you suggested utimer, both .tcl utimer 3 [putlog hi] and .tcl utimer 8000 [putlog hi] return hi instantly. Yes I know about the dump dcc commands and such, but I have special reasons for making what I am.
p
ppslim
Revered One
Posts: 3914
Joined: Sun Sep 23, 2001 8:00 pm
Location: Liverpool, England

Post by ppslim »

using
.tcl utimer 3 [putlog hi]
would return instantly

using the [ ] makes it execute there and then. You are meant to be sending it a list of commands and arguments. In your situation, you are telling the utimer to execute what the command "putlog" returns after 3 seconds.

In this situation (and with the Tcl "after" command), you should use
utimer 3 [list putlog "hi people"]
after 8000 [list putlog "hi people"]
G
Guest

Post by Guest »

ok thanks my mistake on that, but I have a better way than using list (which works)
.tcl after 4000 {putlog hi}
now just need to figure out writable. I can prob get around the problem just calling it myself and check fblocked, well ok thanks for your help.
p
ppslim
Revered One
Posts: 3914
Joined: Sun Sep 23, 2001 8:00 pm
Location: Liverpool, England

Post by ppslim »

using
after 8000 {putlog "hello"}
Is not advisable

It's far simpler to use the "list" command.

An example of where the {} method would fail, is when you want to pass a variable to the command, once the timer has triggered.

EG
in a eggdrop script

Code: Select all

proc onjoin {nick uh hand chan} {
  after 3000 {putlog "$nick join channel 3 seconds ago"}
}
This would work fine, except, if I where to join a channel (with the nickname ppslim) the log file would now have a line looking like
[00:00] $nick join channel 3 seconds ago
instead of desired
[oo:oo] ppslim join channel 3 seconds ago
This is all to do with the way Tcl handles lists.

If you where to let Tcl create the list for you (witht he list command), it would all be fine.

Code: Select all

proc onjoin {nick uh hand chan} {
  after 3000 [list putlog "$nick join channel 3 seconds ago"]
}
User avatar
stdragon
Owner
Posts: 959
Joined: Sun Sep 23, 2001 8:00 pm
Contact:

Post by stdragon »

Ppslim is right about using
  • , you should listen to his advice vxspiritxv.

    As to your second problem, you are right, eggdrop will only run it about once a second, because that is how eggdrop's event loop works. That also means that you can't use the 'after' command with a granularity of less than a second.

    There are ways to get around this, such as by editing src/net.c and reducing the timeout from 1 second to, say, 1/10 second.
G
Guest

Post by Guest »

Is there any other way to get around that 1 second thing with out modifing the source, and/or exec an outside program?
I don't really need it in the after command but I must have it for my fileevent. I saw in the manual Tcl_DoOneEvent(TCL_FILE_EVENTS) but I don't know how to invoke it (if it even does what I want it to do)
Locked