Yea, the timer-value on WINDOWS resets to zero every time the interpreter restarts. I do not think that there is a system timer like on UNIX machines. But one can implement one maybe calculating the UNIXtimer from the clock values. Maybe this would be a good issue for improvement.
Corrently the TIMER does following on WINDOWS:
return((double)clock()/CLOCKS_PER_SEC);
So it uses the OS function "clock()".
I was partially wrong: STIMER works and gives the UNIX-timestamp of the current local time.
However there are no milliseconds. SO maybe It is just a matter of combining the two. This would not be too hard to do.
Last edit: Markus Hoffmann 2019-07-07
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I am using the system timer of WINDOWS plus a UNIX timestamp saved when the TIMER was first used. So this means: STIMER and TIMER can be off by up to 1 Second. Also maybe the systemtimer is not in sync with the clock. So STIMER and TIMER can slightly drift away.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
TIMER is behaving strangely in 1.27-58-unstable in Windows 10 32-bit [Version 10.0.17763.593] when multiple xbasic instances are running,
Yea, the timer-value on WINDOWS resets to zero every time the interpreter restarts. I do not think that there is a system timer like on UNIX machines. But one can implement one maybe calculating the UNIXtimer from the clock values. Maybe this would be a good issue for improvement.
Corrently the TIMER does following on WINDOWS:
return((double)clock()/CLOCKS_PER_SEC);
So it uses the OS function "clock()".
I was partially wrong: STIMER works and gives the UNIX-timestamp of the current local time.
However there are no milliseconds. SO maybe It is just a matter of combining the two. This would not be too hard to do.
Last edit: Markus Hoffmann 2019-07-07
I have fixed this now. TIMER now behaves the same on WINDOWS, LINUX and ANDROID. Can be tested in the next release (1.27-59).
Thanks! In good news, MODE() appears to behave reasonably in Windows 10 32-bit, even if it doesn't clearly detect online-only OneDrive files,
I'm not quite sure how Windows file attributes should map to MODE's in every case,
https://docs.microsoft.com/en-us/windows/win32/fileio/file-attribute-constants
Last edit: Yet Another Troll 2019-07-07
Looks good. There could be some rounding or race condition weirdness going on between TIMER and STIMER, but I can work with this. Thank you.
I am using the system timer of WINDOWS plus a UNIX timestamp saved when the TIMER was first used. So this means: STIMER and TIMER can be off by up to 1 Second. Also maybe the systemtimer is not in sync with the clock. So STIMER and TIMER can slightly drift away.