Hi, I am new on this forum (and Pascal) and I want to tell you all that English is not my first language so sorry about any grammar mistake
I'm working on an application to collect data from a device and I'm using FormatDateTime to show the time elapsed since the application start data collection. However, data collection can take days and when the timer goes over 24 hours it restarts from 0 again. I have tried using different formats described here:
https://www.freepascal.org/docs-html/rtl/sysutils/formatchars.htmlhttps://www.freepascal.org/docs-html/rtl/sysutils/formatdatetime.htmlBut when I use [hh] instead hh the application shows me just the time between brackets
So I am sure I am doing something wrong, could someone help me? please
Here is the detail of my code
procedure TMain.Timer2Timer(Sender: TObject);
begin
Elapsed:=Elapsed+1;
if Running=True then
TNext:=TNext-1
else
TNext:=Time*60;
Label21.caption:=FormatDateTime('hh:nn:ss',Elapsed/86400); //I tried '[hh]:nn:ss' as well
Label23.caption:=FormatDateTime('hh:nn:ss',TNext/86400);
end;
A second thing related to this: The timer in the code above has an interval of 1 second; however after some hours of works I saw that the clock get a delay. I am using in one part of my code the sleep() function, is this affecting the timer?
I am using the delay because I need wait 250-500 ms for the answer from my device when I send the query. An also the sleep() is inside of another Timer...
Here a little more context about this:
procedure TMain.Timer1Timer(Sender: TObject);
var
...
begin
...
BytesWritten := lazserial1.WriteData('SI'+chr(13) + chr (10));
sleep (500) ;
Current := lazserial1.ReadData;
...
end;
I will try changing sleep() function by another timer.
procedure TMain.Timer1Timer(Sender: TObject);
var
...
begin
...
BytesWritten := lazserial1.WriteData('SI'+chr(13) + chr (10));
Timer3.Interval:= 500;
...
end;
procedure TMain.Timer3Timer(Sender: TObject);
begin
...
Current := lazserial1.ReadData;
...
end;
However, as I said it will take hours realise if this solves the problem, so if someone knows what is going on and can guide me I will be thankful.