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.

bind time

Old posts that have not been replied to for several years.
J
Jag
Halfop
Posts: 90
Joined: Fri Sep 19, 2003 10:06 am

bind time

Post by Jag »

what is the bind time of every 90 mins?
10x :)
User avatar
Sir_Fz
Revered One
Posts: 3794
Joined: Sun Apr 27, 2003 3:10 pm
Location: Lebanon
Contact:

Post by Sir_Fz »

Code: Select all

bind time - "90 *" proc
this will trigger proc every 90 minutes.
J
Jag
Halfop
Posts: 90
Joined: Fri Sep 19, 2003 10:06 am

Post by Jag »

Thanks :P
User avatar
GodOfSuicide
Master
Posts: 463
Joined: Mon Jun 17, 2002 8:00 pm
Location: Austria

Post by GodOfSuicide »

Sir_Fz wrote:this will trigger proc every 90 minutes.
are you sure ? either i'm drunk or this proc will never be triggerd.

bind time works with <minute> <hour> <day> <month> <year>
your bind would trigger every hour that has the minute value of 90...this aint gonna happen i'd say.

Code: Select all

proc someproc {args} {
        foreach i [timers] {
         if {[lindex $i 1] == "someproc"} {
             killtimer [lindex $i 2]
         }
        }
       putlog "TRIGGERD ALL 90 MINS"
       timer 90 someproc
}

timer 90 someproc
User avatar
Sir_Fz
Revered One
Posts: 3794
Joined: Sun Apr 27, 2003 3:10 pm
Location: Lebanon
Contact:

Post by Sir_Fz »

GodOfSuicide wrote:[snip]
bind time works with <minute> <hour> <day> <month> <year>
your bind would trigger every hour that has the minute value of 90...this aint gonna happen i'd say.
[snip]
If I understand well, what you mean is that there can't be 90 mins in a clock (since 1 hour = 60mins) well if that's how bind time functions (because I don't exactly know how bind time functions) then my bind is wrong, else its correct.
User avatar
GodOfSuicide
Master
Posts: 463
Joined: Mon Jun 17, 2002 8:00 pm
Location: Austria

Post by GodOfSuicide »

Sir_Fz wrote: If I understand well, what you mean is that there can't be 90 mins in a clock (since 1 hour = 60mins) well if that's how bind time functions
bind time is for exact values.

bind time 00 ** ** ** ** (or even 00 *) would trigger every full hour (00:00, 01:00, 02:00, etc)
bind time ?0 ** ** ** ** (or even ?0 *) would trigger all 10 minutes (00:00, 00:10, 00:20, etc)
User avatar
arcane
Master
Posts: 280
Joined: Thu Jan 30, 2003 9:18 am
Location: Germany
Contact:

Post by arcane »

edit: sorry... guess i'm too ill to think today.
aVote page back online!
Check out the most popular voting script for eggdrop bots.

Join the metal tavern!
User avatar
Sir_Fz
Revered One
Posts: 3794
Joined: Sun Apr 27, 2003 3:10 pm
Location: Lebanon
Contact:

Post by Sir_Fz »

yeah, got that :) Thanx for the info.
User avatar
user
&nbsp;
Posts: 1452
Joined: Tue Mar 18, 2003 9:58 pm
Location: Norway

Workaround for the "limits" to bind time

Post by user »

Code: Select all

# interval in minutes
# (you could of course hard code the interval value into the
# proc if you don't need it to be easy to spot and change :)
set interval 90

# this bind will trigger the proc every ten minutes
# (whenever the last digit of the minutes is "0")
bind time - ?0* timedThing

proc timedThing args {
	# this calculation makes sure the code is only executed
	# at the given interval
	if {![expr {([clock sec]/60)%$::interval}]} {
		# insert your code here
	}
}
PS: since the proc is only triggered every ten minutes, make sure your interval value matches that (ends with a 0). If you need a finer "resolution", change the bind. (* as a mask for every minute)
Have you ever read "The Manual"?
User avatar
GodOfSuicide
Master
Posts: 463
Joined: Mon Jun 17, 2002 8:00 pm
Location: Austria

Post by GodOfSuicide »

user: i think the direct timer works a little better :P
User avatar
user
&nbsp;
Posts: 1452
Joined: Tue Mar 18, 2003 9:58 pm
Location: Norway

Post by user »

GodOfSuicide wrote:user: i think the direct timer works a little better :P
In what way? The code doing the check for an existing timer is much more cpu intensive than my time calculation and the eggdrop code dealing with timers / bind time is pretty much the same (iirc)
Have you ever read "The Manual"?
User avatar
GodOfSuicide
Master
Posts: 463
Joined: Mon Jun 17, 2002 8:00 pm
Location: Austria

Post by GodOfSuicide »

user wrote:The code doing the check for an existing timer is much more cpu intensive than my time calculation
the call for [timers] is only triggered when the actual proc is hit, it's used to avoid double timers when doing a rehash / whatever.

if the intervall would be 10000000 (or something large) your code would check a few hundret times it the exact has been reached (either that or i'm too drunk to understand the code again).
User avatar
user
&nbsp;
Posts: 1452
Joined: Tue Mar 18, 2003 9:58 pm
Location: Norway

Post by user »

If you want an interval that large, it's usually a number of hours/days. (change the bind/calculation) His request was for 90 minutes though.
I like the idea of just having to unbind to stop it and the fact that it's running "in sync" with the time. (so you can predict when the proc will run your code without having to know when the script was started/start it at a particular time.)

He might not want that though :)

On the downside, the code matching the masks for a time bind doesn't handle timer drifts very well (iirc), so you might get a few skipped runs if the box you're running it on is REALLY busy around the time your bind mask matches.

/me's just trying to pick a fight as always :P
Have you ever read "The Manual"?
User avatar
GodOfSuicide
Master
Posts: 463
Joined: Mon Jun 17, 2002 8:00 pm
Location: Austria

Post by GodOfSuicide »

user wrote: /me's just trying to pick a fight as always :P
ok, lets take this one outside :D *maybe closed*
L
LtPhil
Voice
Posts: 26
Joined: Mon Jul 28, 2003 10:25 am

Post by LtPhil »

i actually have a related question...

i'd like to use a bind time to trigger something to run every five minutes (i want to make sure it executes at :00 :05 :10, etc)... how do i do this? can you comma-separate multiple values like you can with crontab, or do i have to set up two binds?

crontab-style:

Code: Select all

bind time - "?0,?5 *" myProc
two timers:

Code: Select all

bind time - "?0 *" myProc
bind time - "?5 *" myProc
thanks, as always, for any help :)
Locked