Jump to content
kimi18

Timer

Recommended Posts

Hello

Sorry my bad english :)

 

This is my script, but not good :(

program New;

var

myDate: TDateTime;

myVmi: double;

myTime: string;

begin

repeat

myDate := Time;

myTime := FormatDateTime('tt', myDate);

Status('It is now '+myTime);

wait(1000);

writeln(myTime);

until (myTime = '06:20:25');

 

end.

 

I need script, that stop example when the time 06:20:25. This script dont stop 06:20:25, but why? :)

Thanks help.

Link to comment
Share on other sites

Not really cause it's outputting every second. And I had this run for a good 20mins.

 

Nothing is ever exact. You never want to use =, instead >= if possible. Strings are not the right type for this. It is very easy for it to never be the correct string at the correct time it is checked at the end of the loop.

Link to comment
Share on other sites

Nothing is ever exact. You never want to use =, instead >= if possible. Strings are not the right type for this. It is very easy for it to never be the correct string at the correct time it is checked at the end of the loop.

 

 

:/. It didn't seem like it was needed.

Link to comment
Share on other sites

So in the high chance that it doesn't check that exact time at the end of that loop it will repeat forever, an even higher chance considering a loop is brought back up multiple times. Especially if it wasn't something simple like this that had more stuff in the loop the would greatly affect the time. This is horrible practice and should never be used regardless of the situation, this is exactly how intermittent problems happen.

Link to comment
Share on other sites

So in the high chance that it doesn't check that exact time at the end of that loop it will repeat forever, an even higher chance considering a loop is brought back up multiple times. Especially if it wasn't something simple like this that had more stuff in the loop the would greatly affect the time. This is horrible practice and should never be used regardless of the situation, this is exactly how intermittent problems happen.

 

I was only solving his issue. A simple "if" could be added though so that doesn't happen.

 

The only high chance would be if a hour went back/forward. Which he could have noticed himself.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



×
  • Create New...