| ECS-L Home Automation and Security Archives |
| Subject: From: Date: | RE: [ECS] Elapsed time calculator Jeff Boyes Thu, 27 Jul 2000 21:51:04 -0600 |
A.J.,
Came out fine on my end. By the way, thanks for sharing this event, and
others. I especially like the NASCAR Point Standings!
Jeff
-----Original Message-----
From: A.J. Griglak [mailto:aj@griglak.com]
Sent: Thursday, July 27, 2000 5:04 PM
To: ECS List
Subject: [ECS] Elapsed time calculator
Thought I'd share with everyone something I just whipped up. This event,
when called, will turn a variable NUMBER-A into TEXT-A, calculating weeks,
days, hours, and minutes. It is meant to be called from another event. For
example, I set a MINUTE-COUNTER called Away Timer when I leave the house
that runs until I get back. Then, when I get back, it translates it into
weeks, days, etc. The resulting TEXT-A item looks something like this:
2 weeks, 1 day, 13 hours, and 2 minutes.
20 hours, and 1 minute.
Note that ECS's limit for a number is 32,765 [NOT 32,767 as mentioned in
ECS.HTM], which is
3 weeks, 1 day, 18 hours, and 5 minutes.
Hopefully, it will be of some use to someone.-=A.J.
_Part_ of my Home/Away Event:
BEGINIF At_home:Someone Is Now True
Then Away Timer Set Stop
;----------Calculate elapsed time gone Do Number-A
Set Away Timer Do Event-Call
Set Calc: Elapsed time Do Text-A
Set Log/Speak Do Text-A Set
Re-Define Text Do Away Timer Set
0
--------------------Item:Timer:Elapsed Days Type:Number
Acc:User/User Initial State:(none)
Backup:NoItem:Timer:Elapsed Hours Type:Number
Acc:User/User Initial State:(none)
Backup:NoItem:Timer:Elapsed Minutes Type:Number
Acc:User/User Initial State:(none)
Backup:NoItem:msg:Days Type:Text
Acc:User/User Initial State:(none)
Backup:No Text :daysItem:msg:Hours Type:Text
Acc:User/User Initial State:(none)
Backup:No Text :hoursItem:msg:minutes
Type:Text Acc:User/User Initial State:(none)
Backup:No Text :minutesItem:msg:And
Type:Text Acc:User/User Initial State:(none)
Backup:No Text :andItem:Timer:Elapsed Weeks
Type:Number Acc:User/User Initial State:(none)
Backup:NoItem:msg:Weeks Type:Text
Acc:User/User Initial State:(none)
Backup:No Text :weeksItem:msg:Week
Type:Text Acc:User/User Initial State:(none)
Backup:No Text :weekItem:msg:Day Type:Text
Acc:User/User Initial State:(none)
Backup:No Text :dayItem:msg:hour Type:Text
Acc:User/User Initial State:(none)
Backup:No Text :hourItem:msg:minute Type:Text
Acc:User/User Initial State:(none)
Backup:No Text :minuteEvent: Calc: Elapsed time
Called ?:Yes
;-------------------------------------------------------------------
;This event takes a number passed to it in minutes ;and calculates
the elapsed weeks, days, hours, and minutes. ; ;The number
should be passed to it in the variable Number-A ; ;The result
will be in the variable Text-A
;-------------------------------------------------------------------
; ;----------Reset variables Do Text-A
Set Re-Define Text ; Do Timer:Elapsed Weeks
Set 0 Do Timer:Elapsed Days Set 0
Do Timer:Elapsed Hours Set 0 ; ;
WHILE Number-A Is GT 10080 Do
Timer:Elapsed Weeks Add 1 Do Number-A
Subtract 10080 ENDWHILE ; WHILE Number-A
Is LT 10080 And Number-A Is GE
1440 Do Timer:Elapsed Days Add 1 Do
Number-A Subtract 1440 ENDWHILE ;
WHILE Number-A Is LT 1440 And Number-A
Is GE 60 Do Timer:Elapsed Hours Add 1
Do Number-A Subtract 60 ENDWHILE ;
BEGINIF Timer:Elapsed Weeks Is GT 0 Do Text-A
T1/A<-Stt Timer:Elapsed Weeks Do Text-A
Set <Space> If Timer:Elapsed Weeks Is
1 Then Text-A T1/A<-T1 msg:Week
Else Text-A T1/A<-T1 msg:Weeks Do
Text-A Set , Do Text-A
Set <Space> ENDIF ; ; BEGINIF
Timer:Elapsed Days Is GT 0 Do Text-A
T1/A<-Stt Timer:Elapsed Days Do Text-A
Set <Space> If Timer:Elapsed Days Is
1 Then Text-A T1/A<-T1 msg:Day Else
Text-A T1/A<-T1 msg:Days Do Text-A
Set , Do Text-A Set
<Space> ENDIF ; BEGINIF Timer:Elapsed Hours Is GT
0 Do Text-A T1/A<-Stt Timer:Elapsed Hours
Do Text-A Set <Space> If
Timer:Elapsed Hours Is 1 Then Text-A
T1/A<-T1 msg:hour Else Text-A T1/A<-T1
msg:Hours Do Text-A Set , Do
Text-A Set <Space> Do Text-A
T1/A<-T1 msg:And Do Text-A Set
<Space> ENDIF ; Do Timer:Elapsed Minutes Set
Number-A Do Text-A T1/A<-Stt
Timer:Elapsed Minutes Do Text-A Set
<Space> If Timer:Elapsed Minutes Is 1 Then
Text-A T1/A<-T1 msg:minute Else Text-A
T1/A<-T1 msg:minutes Do Text-A Set
. ; End
-----Original Message-----
From: A.J. Griglak [mailto:aj@griglak.com]
Sent: Thursday, July 27, 2000 5:04 PM
To: ECS List
Subject: [ECS] Elapsed time calculatorThought I'd share with everyone something I just whipped up. This event, when called, will turn a variable NUMBER-A into TEXT-A, calculating weeks, days, hours, and minutes. It is meant to be called from another event. For example, I set a MINUTE-COUNTER called Away Timer when I leave the house that runs until I get back. Then, when I get back, it translates it into weeks, days, etc. The resulting TEXT-A item looks something like this:
2 weeks, 1 day, 13 hours, and 2 minutes.20 hours, and 1 minute.Note that ECS's limit for a number is 32,765 [NOT 32,767 as mentioned in ECS.HTM], which is3 weeks, 1 day, 18 hours, and 5 minutes.
Hopefully, it will be of some use to someone.
-=A.J.
Part of my Home/Away Event:
BEGINIF At home:Someone Is Now True
Then Away Timer Set Stop
;----------Calculate elapsed time gone
Do Number-A Set Away Timer
Do Event-Call Set Calc: Elapsed time
Do Text-A Set Log/Speak
Do Text-A Set Re-Define Text
Do Away Timer Set 0
--------------------
Item:Timer:Elapsed Days Type:Number Acc:User/User
Initial State:(none) Backup:No
Item:Timer:Elapsed Hours Type:Number Acc:User/User
Initial State:(none) Backup:No
Item:Timer:Elapsed Minutes Type:Number Acc:User/User
Initial State:(none) Backup:No
Item:msg:Days Type:Text Acc:User/User
Initial State:(none) Backup:No
Text :days
Item:msg:Hours Type:Text Acc:User/User
Initial State:(none) Backup:No
Text :hours
Item:msg:minutes Type:Text Acc:User/User
Initial State:(none) Backup:No
Text :minutes
Item:msg:And Type:Text Acc:User/User
Initial State:(none) Backup:No
Text :and
Item:Timer:Elapsed Weeks Type:Number Acc:User/User
Initial State:(none) Backup:No
Item:msg:Weeks Type:Text Acc:User/User
Initial State:(none) Backup:No
Text :weeks
Item:msg:Week Type:Text Acc:User/User
Initial State:(none) Backup:No
Text :week
Item:msg:Day Type:Text Acc:User/User
Initial State:(none) Backup:No
Text :day
Item:msg:hour Type:Text Acc:User/User
Initial State:(none) Backup:No
Text :hour
Item:msg:minute Type:Text Acc:User/User
Initial State:(none) Backup:No
Text :minute
Event: Calc: Elapsed time Called ?:Yes
;-------------------------------------------------------------------
;This event takes a number passed to it in minutes
;and calculates the elapsed weeks, days, hours, and minutes.
;
;The number should be passed to it in the variable Number-A
;
;The result will be in the variable Text-A
;-------------------------------------------------------------------
;
;----------Reset variables
Do Text-A Set Re-Define Text
;
Do Timer:Elapsed Weeks Set 0
Do Timer:Elapsed Days Set 0
Do Timer:Elapsed Hours Set 0
;
;
WHILE Number-A Is GT 10080
Do Timer:Elapsed Weeks Add 1
Do Number-A Subtract 10080
ENDWHILE
;
WHILE Number-A Is LT 10080
And Number-A Is GE 1440
Do Timer:Elapsed Days Add 1
Do Number-A Subtract 1440
ENDWHILE
;
WHILE Number-A Is LT 1440
And Number-A Is GE 60
Do Timer:Elapsed Hours Add 1
Do Number-A Subtract 60
ENDWHILE
;
BEGINIF Timer:Elapsed Weeks Is GT 0
Do Text-A T1/A<-Stt Timer:Elapsed Weeks
Do Text-A Set <Space>
If Timer:Elapsed Weeks Is 1
Then Text-A T1/A<-T1 msg:Week
Else Text-A T1/A<-T1 msg:Weeks
Do Text-A Set ,
Do Text-A Set <Space>
ENDIF
;
;
BEGINIF Timer:Elapsed Days Is GT 0
Do Text-A T1/A<-Stt Timer:Elapsed Days
Do Text-A Set <Space>
If Timer:Elapsed Days Is 1
Then Text-A T1/A<-T1 msg:Day
Else Text-A T1/A<-T1 msg:Days
Do Text-A Set ,
Do Text-A Set <Space>
ENDIF
;
BEGINIF Timer:Elapsed Hours Is GT 0
Do Text-A T1/A<-Stt Timer:Elapsed Hours
Do Text-A Set <Space>
If Timer:Elapsed Hours Is 1
Then Text-A T1/A<-T1 msg:hour
Else Text-A T1/A<-T1 msg:Hours
Do Text-A Set ,
Do Text-A Set <Space>
Do Text-A T1/A<-T1 msg:And
Do Text-A Set <Space>
ENDIF
;
Do Timer:Elapsed Minutes Set Number-A
Do Text-A T1/A<-Stt Timer:Elapsed Minutes
Do Text-A Set <Space>
If Timer:Elapsed Minutes Is 1
Then Text-A T1/A<-T1 msg:minute
Else Text-A T1/A<-T1 msg:minutes
Do Text-A Set .
;
End