Triggers, passing multiple variables

Posted by Sleaker on Sat 24 Aug 2002 06:21 AM — 5 posts, 25,563 views.

#0
okay I have a alias.

conint *
Script: ContactTimerInterval

and the VBS script it calls.

Sub ContactTimerInterval(thename, theoutput, theparameters)

If World.GetVariable("ContactTimer") = "ON" And IsNumeric(Trim(theparameters(1))) = TRUE Then

world.SetVariable "ConTimerInterval", Trim(theparameters(1))

world.note "Contact Timer Interval Set to: " &

World.GetVariable("ConTimerInterval") & " seconds."

World.DeleteTimer "ContactTimer"

World.AddTimer "ContactTimer", 0, 0, Trim(theparameters(1)), "contacts", 1, ""

ElseIf (World.GetVariable("ContactTimer") = "OFF") Then

World.note "You must enable the Contact Timer before setting the interval."

Else

World.note "The current Contact Timer Interval is set to: " & World.GetVariable("ConTimerInterval") & " seconds."

End If
End Sub

I want it to take any Number over 59 and change it to Hours Minutes Seconds, then pass it to the AddTimer function.

So would I do as follows?



then run a While loop that While TRIM(theparameters(1)) is
greater than 60 it does
TRIM(theparameters(1)) - 60 and

World.SetVaraible "ContactIntervalMinutes", +1
or how do you add 1 to a variable?
then after seconds are finished it sets
World.SetVariabliable "ContactIntervalSeconds", TRIM(theparameters(1))

and then finally it checks for hours the same way with a while loop. then uses all that info and sets the Timer.
Australia Forum Administrator #1
First, if you use DoAfter instead of AddTimer it takes seconds instead of hours/minutes/seconds.

Second, to convert seconds to the other things you really need to divide by 60.

eg.

hours = CInt (seconds / 3600)

(The CInt converts to an integer, ie. a whole number).

Now get the remainder...

seconds = seconds - (hours * 3600)

Now for minutes ...

minutes = CInt (seconds / 60)

seconds = seconds - (minutes * 60)
#2
hrm, converting Seconds to Hours & Minutes & Seconds, why can't I run a While loop that subtracts 60 seconds and adds 1 minute, then stops when it can't subtract 60. How would that not work?
#3
mm okay I see whatcha mean :D yes your way is easiest hehe
Canada #4
I just posted this in another thread:

Function TimeDiff (StartTime, EndTime)
	Dim Hours, Minutes, Seconds
	Seconds = DateDiff("s", StartTime, EndTime)
	If Seconds > 90000 Then Seconds = 90000
	If Seconds < 0 Then Seconds = 0
	Minutes = Seconds / 60
	Minutes = Fix(Minutes)
	Seconds = Seconds - (Minutes * 60)
	Hours = Minutes / 60
	Hours = Fix(Hours)
	Minutes = Minutes - (Hours * 60)
	Seconds = CStr(Seconds)
	Minutes = CStr(Minutes)
	Hours = CStr(Hours)
	If Len(Seconds) = 1 Then Seconds = "0" + Seconds
	If Len(Minutes) = 1 Then Minutes = "0" + Minutes
	If Len(Hours) = 1 Then Hours = "0" + Hours
	TimeDiff = Hours & ":" & Minutes & ":" & Seconds
End Function

Elsewhere in my script, I grab the current time with the VBS function: Now()

I wrote the function above to subtract two different "Now()" values, and present the results in the format "hh:mm:ss".

(I wanted to strip the date, which is included with the VBS function "DateDiff").

I check to make sure the seconds isn't too high (above 25 hours). This is because sometimes my triggers would inadvertantly call this script when the start time had not been initialized, and an error in the values would cause a runtime error.

Anyway, you can see how I do the conversion you are talking about...