Hello,
Still using Basic4PPC to write some desktop applications. My problem with this one; is I am creating a log file for feeding into a commercial app. The file format is a new log file created every hour (or part thereof) with sequential number, a small header, minute markers and five second markers. The file will get filled with other events as they occur - not to be worried about now.
So, I have a 5000ms timer control, but we all know the number of Ticks is at the whim of the OS and my calibration code does a good job of keeping the 5 second timer within a couple of hundredths of a second, well within the accuracy I need.
My problem is if the timer ticks too early when it is on a whole minute; say 09:59:59.98 seconds. It was then not placing a minute marker as the If statement 'If TimeSecond(T)=0' would return False. As a crude workaround, I preceded it with 'If TimeSecond(T)=59 Then T=T+cTicksPerSecond' so it would hopefully resolve that it was at a minute and place the minute marker.
Sometimes it still fails to place the minute marker. I have included some code to dump what the ticks value was at the time it failed; and each time the Timer ticked just before the minute as above.
Please let the code run for a few hours and you'll (hopefully) see a couple of files that have 23 five-second markers between minute markers - instead of 11. The debug file will show the tick value that was used at the time.
Is it because I'm using the wrong variable type for T? Please change the file extension from .txt to .sbp.
Still using Basic4PPC to write some desktop applications. My problem with this one; is I am creating a log file for feeding into a commercial app. The file format is a new log file created every hour (or part thereof) with sequential number, a small header, minute markers and five second markers. The file will get filled with other events as they occur - not to be worried about now.
So, I have a 5000ms timer control, but we all know the number of Ticks is at the whim of the OS and my calibration code does a good job of keeping the 5 second timer within a couple of hundredths of a second, well within the accuracy I need.
My problem is if the timer ticks too early when it is on a whole minute; say 09:59:59.98 seconds. It was then not placing a minute marker as the If statement 'If TimeSecond(T)=0' would return False. As a crude workaround, I preceded it with 'If TimeSecond(T)=59 Then T=T+cTicksPerSecond' so it would hopefully resolve that it was at a minute and place the minute marker.
Sometimes it still fails to place the minute marker. I have included some code to dump what the ticks value was at the time it failed; and each time the Timer ticked just before the minute as above.
Please let the code run for a few hours and you'll (hopefully) see a couple of files that have 23 five-second markers between minute markers - instead of 11. The debug file will show the tick value that was used at the time.
Is it because I'm using the wrong variable type for T? Please change the file extension from .txt to .sbp.