Page 1 of 1
[14 Nov 2008] Comparing time stamps
Posted: Sat Jun 13, 2020 5:32 pm
by Clyde
Note: This is an archived post that was originally sent to the Hollywood mailing list on Fri, 14 Nov 2008 15:27:40 +0100
Hi there,
I want to compare two time stamps returned by
GetFileAttributes(). This is my code:
Code: Select all
t$ = GetFileAttributes("Ram:myfile1.txt")
timeOld$ = t$.time
If GetFileAttributes("Ram:myfile2.txt") > timeOld$
DebugPrint("YES!")
Else
DebugPrint("NO!")
EndIf
Unfortunately that doesn't work, as < and > don't seem to be support the time stamps. So, I can I compare two file dates?
Thanks a lot in advance!
Micha
[14 Nov 2008] Re: Comparing time stamps
Posted: Sat Jun 13, 2020 5:32 pm
by PEB
Note: This is an archived post that was originally sent to the Hollywood mailing list on Fri, 14 Nov 2008 08:39:13 -0800 (PST)
That is because you are trying to compare a variable with a table. Try the following code instead:
Code: Select all
t$ = GetFileAttributes("Ram:myfile1.txt")
timeOld$ = t$.time
t$=GetFileAttributes("Ram:myfile2.txt")
timeNew$ = t$.time
If timeNew$ > timeOld$
DebugPrint("YES!")
Else
DebugPrint("NO!")
EndIf
[14 Nov 2008] Re: Comparing time stamps
Posted: Sat Jun 13, 2020 5:32 pm
by Clyde
Note: This is an archived post that was originally sent to the Hollywood mailing list on Fri, 14 Nov 2008 21:04:13 +0100
Arrghl ... Yeah, you are right! Man, I was blind (or just dumb

). This works, thank you very much!
Cheers, Micha
[14 Nov 2008] Re: Comparing time stamps
Posted: Sat Jun 13, 2020 5:32 pm
by airsoftsoftwair
Note: This is an archived post that was originally sent to the Hollywood mailing list on Fri, 14 Nov 2008 21:09:03 +0100
Arrghl ... Yeah, you are right! Man, I was blind (or just dumb

). This works, thank you very much!
No no no nooooooo, it's not that easy

You can't compare time stamps like that. Check the contents of t.time. It is a string like:
14-Nov-08 21:06:23
If you use the lesser than/greater than operators on such a string it does a simple alphabetical compare. e.g.
Code: Select all
"a" > "b" ----> FALSE
"c" > "b" ----> TRUE
If you want to compare time stamps to see which is older or newer, you'll have to do it the hard way: viz. split up the string and compare all components (year, month, day, hour, minute, second). Admittedly, a Hollywood function which does this would be a desideratum
[14 Nov 2008] Re: Comparing time stamps
Posted: Sat Jun 13, 2020 5:32 pm
by Clyde
Note: This is an archived post that was originally sent to the Hollywood mailing list on Fri, 14 Nov 2008 21:16:41 +0100
No no no nooooooo, it's not that easy
It would have been so nice ...
If you use the lesser than/greater than operators on such a string it does a simple alphabetical compare. e.g.
"a" > "b" ----> FALSE "c" > "b" ----> TRUE
Ok, I see.
If you want to compare time stamps to see which is older or newer, you'll have to do it the hard way: viz. split up the string and compare all components (year, month, day, hour, minute, second).
Ah, ok, an easy one ...

No, seriously, thanks a lot for that hint!
Admittedly, a Hollywood function which does this would be a desideratum

Definitely!

And if I can say another wish for HW4: Support for increment (++) and decrement (--) operators would be very nice!
Thanks and cheers, Micha
[14 Nov 2008] Re: Comparing time stamps
Posted: Sat Jun 13, 2020 5:32 pm
by airsoftsoftwair
Note: This is an archived post that was originally sent to the Hollywood mailing list on Fri, 14 Nov 2008 21:44:04 +0100

Definitely!

And if I can say another wish for HW4: Support for increment (++) and decrement (--) operators would be very nice!
That's a lot of work because it affects essential parts of the VM. I rather opt for a
CompareDates() function