Zabaware Support Forums

Time since the last time...

Started by Larry, September 15, 2003, 05:48:44 PM

Previous topic - Next topic

Larry

--> Edited - Thanks to lostbowyer !!! <--

How would you like Hal to tell you he missed you since you've been gone over 10 minutes now???

First you got find this in your brain
'PROCESS: RECORD TIME
'Record the current time, so Hal knows the time in between sentences.
LastResponseTime = Now

Make sure you've made a backup of your brain first! Then change it to this
'PROCESS: RECORD TIME
'Record the current time, so Hal knows the time in between sentences.
'LastResponseTime = Now
Min = Minute(Time)
Hrs = Hour(Time)
If Len(Min) < 2 Then Min = "0" & Min
If Len(Hrs) < 2 Then Hrs = "0" & Hrs
LastResponseTime = Hrs & Min

Then after the
'RESPOND: CALL GREETING FUNCTION section add this -->
If LastResponseTime = "" then
Min = Minute(Time)
Hrs = Hour(Time)
If Len(Min) < 2 Then Min = "0" & Min
If Len(Hrs) < 2 Then Hrs = "0" & Hrs
LastResponseTime = Hrs & Min
End If
HourDay = CInt(Hour(Time)) '(will yeild the hour in military time)
MinuteDay = CInt(Minute(Time)) '(will yield the minutes)
DebugInfo = DebugInfo & "LastResponseTime: " & LastResponseTime & vbCrLf
TempLastHourDay = 0
TempLastMinuteDay = 0
LastHourDay = 0
LastMinuteDay = 0
TempLastHourDay = Left(CStr(LastResponseTime),2)
TempLastMinuteDay = Right(CStr(LastResponseTime),2)
LastHourDay = CInt(TempLastHourDay)
LastMinuteDay = CInt(TempLastMinuteDay)
DebugInfo = DebugInfo & "Now: " & HourDay & ":" & MinuteDay & vbCrLf
DebugInfo = DebugInfo & "Last: " & LastHourDay & ":" & LastMinuteDay & vbCrLf
If CInt(HourDay) < CInt(LastHourDay) Then HourDay = CInt(HourDay) + 23
Temphour = CInt(HourDay) * 60
LTemphour = CInt(LastHourDay) * 60
If CInt(MinuteDay) < CInt(LastMinuteDay) Then MinuteDay = CInt(MinuteDay) + 60
TempMinute = CInt(MinuteDay) + CInt(Temphour)
LTempMin = CInt(LastMinuteDay) + CInt(LTemphour)
GGoneM = CInt(TempMinute) - CInt(LTempMin)
If GGoneM > 10 Then
GetResponse = "And where have you been all this time?" & vbCrLf
If InStr(PrevUserSent, "?") > 0 Then
GetResponse = GetResponse & "Last time you asked, " & PrevUserSent & vbCrLf
Else
GetResponse = GetResponse & "Last time you said, " & PrevUserSent & vbCrLf
End If
If InStr(PrevSent, "?") > 0 Then
GetResponse = GetResponse & "And I asked, " & PrevSent & vbCrLf
Else
GetResponse = GetResponse & "And I said, " & PrevSent & vbCrLf
End If
GGoneH = GGoneM / 60
DebugInfo = DebugInfo & "You have been gone at least: " & GGoneH & " Hours." & vbCrLf
End If

Now this will only work during the current session and with 10 minutes since the last exchange. It won't tell you anything across days...
 

lostbowyer

Larry
You're doing a lot of work to separate the time when you don't have to, didn't you take a look at the lunch script, it is am/pm time aware. To get hours and minutes just do this

Hourday = Hour(Time) (will yeild the hour in military time)
MinuteDay = Minute(Time) (will yield the minutes)

A lot less coding, I'm waiting for the 5.o editor, but it shouldn't be too hard to expand the time concept to yesterday, today, tomorrow

Glenn
 

Larry

#2
Thanks... I didn't know about those other commands...

I'm still trying to figure out how to write and read from a file directly... any tips there???

And by the way... I know there is such a thing as day of the year... ie, Dec. 31 is something like 365... Is there a command for that???