[fpc-pascal] Getting Last User Input reliably

James Richters james.richters at productionautomation.net
Sun Dec 5 17:10:02 CET 2021


Indeed keeping it a DWord solves all the problems for any amount of time less than the 49.7 day rollover time and I don't even have to check for the rollover because it takes care of itself by doing unsigned arithmetic.

Is there even such a thing as overflow checking for DWord variables?

I did some tests and went to go turn on Overflow checking just to see what would happen... and noticed it was on already...
but I noticed it's called "Integer Overflow Checking" which seems it would not apply to things specifically set as DWord.  
I did some searches and didn't come across any overflow checking that wasn't for integers.

Am I missing something?  Or is this not even an issue because there is no overflow checking for DWord variables anyway?

So the only thing I need to consider is times of longer than 49.7 days without user input... because if it was exactly 50 days, it would look like 0.3 days as the first rollover would be forgotten.
To take care of this I can just check it in my main program loop and keep updating my own datetime variable of last user input.
This way I'm checking it often enough that I can't ever have more than one rollover between checks.. 
and the math all fixes itself... after being sure to keep it all Dword
My program will be running anyway...  and even if it's not it won't matter because I will cause user input when I start it.

James 



More information about the fpc-pascal mailing list