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.

usage of "after" command

Help for those learning Tcl or writing their own scripts.
Post Reply
User avatar
Dedan
Master
Posts: 260
Joined: Wed Jul 09, 2003 10:50 pm
Location: Memphis

usage of "after" command

Post by Dedan »

i searched the forum and found nothing to my suprise.

i am having a problem finding the
proper format of this command, i
am not even sure it can be used in
the way i need it.

I have a loop that will loop about
60,000 times and i want to place a "pause"
in it.

Code: Select all


  foreach t $tenthousands {
    blah
    blah
    after 
  }


thanks for you help 8)
I once was an intelligent young man, now i am old and i can not remember who i was.
d
deadite66
Halfop
Posts: 74
Joined: Mon May 30, 2005 2:49 am
Location: Great Yarmouth, UK

Post by deadite66 »

http://www.tcl.tk/man/tcl8.4/TclCmd/after.htm

i believe the after command in eggdrop has to run a command/proc you can't use it as a pause.

i tried it once in a script as a pause and the irc logs times recorded were all out of sync.
<- tcl newb
User avatar
De Kus
Revered One
Posts: 1361
Joined: Sun Dec 15, 2002 11:41 am
Location: Germany

Post by De Kus »

Well I haven't used after till now, because I did not have a reason for it till now. First you will not be able to use it withing a loop of any kind. Best you save were you have been in a global var or forward it via argument and then call the command from the beginning. If I read manual right you should be able to able to use it like:

Code: Select all

after 100 myproc $myarg1 $myarg2 $myarg3 $position
should execute it after 100ms. But I am not sure if this will really work in eggdrops. Maybe you can use the event functions built in eggdrop. No idea if custom events can be bound like "bind evnt - custom proc" and trigger with "event custom".
I personally would try to optimize the script to not consume that much CPU time, because I would probably get kicked of my shell for doing so :D.

Edit:

Code: Select all

[-RO^Bot-] [12:16:22] tcl: evaluate (.tcl): set testtime [clock clicks -milliseconds]; after 1000 putdcc 13 {[expr {[clock clicks -milliseconds] - $testtime}]ms}
[-RO^Bot-] Tcl: after#5
[-RO^Bot-] 1010ms
works like a charm
De Kus
StarZ|De_Kus, De_Kus or DeKus on IRC
Copyright © 2005-2009 by De Kus - published under The MIT License
Love hurts, love strengthens...
Post Reply