| ECS-L Home Automation and Security Archives |
| Subject: From: Date: | RE: [ECS] Elapsed time calculator A.J. Griglak Thu, 27 Jul 2000 22:52:18 -0400 |
Hmmm... It looks good in my email client (Outlook 2000). I tried to format
it so all the characters would line up... Oh, well....
It's attached as a .txt file.
-=A.J.
-----Original Message-----
From: J Gary Mull [mailto:jgary@mindspring.com]
Sent: Thursday, July 27, 2000 8:52 PM
To: ecs-list@netbloc.com
Subject: Re: [ECS] Elapsed time calculator
Your note sounds interesting, but the copy of the event was in some
ancient language that Jesus must have spoken! HA! Can't read it.
At 07:03 PM 7/27/00 -0400, you wrote:
>>>>
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.
-----Original Message-----Your note sounds interesting, but the copy of the event was in some ancient language that Jesus must have spoken! HA! Can't read it.
From: J Gary Mull [mailto:jgary@mindspring.com]
Sent: Thursday, July 27, 2000 8:52 PM
To: ecs-list@netbloc.com
Subject: Re: [ECS] Elapsed time calculator
At 07:03 PM 7/27/00 -0400, you wrote:
>>>>
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.
/fontfamily>
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.
/fontfamily>
Hopefully, it will be of some use to someone.
-=A.J.
;This is a part of the event that calls Calc:Elapsed Time
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