Re: delphi console application

Posted by Rick on December 29, 2007

In Reply to Re: delphi console application posted by Rick on December 28, 2007

: : Hi yes that is what i mean if thats not possible then would it be possible to press a key to start the count then press another to stop it with it counting up one each second or something similar :-S sorry to be a pain lol
: In a Delphi console application, you could do something like this, in order to measure the time interval: ...
: I'll look up the actual code for getting the current time & I'll post it tomorrow ;)

OK, here's the entire program ;) as tested 5 minutes ago:

program Timer1;
{$APPTYPE CONSOLE}
uses Windows, SysUtils;
var T1, T2: integer;
begin
  WriteLn('Press ENTER to start the timer, then press ENTER again to stop it');
  ReadLn; // wait for ENTER
  // GetTickCount gives duration of time since system was started
  T1 := GetTickCount;
  ReadLn; // wait for ENTER
  T2 := GetTickCount;
  WriteLn('Elapsed time, milliseconds: ', IntToStr(T2 - T1));
  ReadLn; // wait for ENTER to stop program
end.

Related articles

       

Follow Ups