home *** CD-ROM | disk | FTP | other *** search
/ ProfitPress Mega CDROM2 …eeware (MSDOS)(1992)(Eng) / ProfitPress-MegaCDROM2.B6I / GRAPHICS / PLOT / MVIS.ZIP / TIME.PAS < prev   
Encoding:
Pascal/Delphi Source File  |  1991-07-01  |  1.1 KB  |  54 lines

  1. UNIT Time;
  2.  
  3. interface
  4.  
  5. uses Dos;
  6.  
  7. procedure RestartTimer; {Think of it like starting a stopwatch.}
  8. function Elapsed:real;  {How many seconds elapsed since I hit the stopwatch?}
  9. function ElapsedStr:string; {result of "Elapsed" in string form.}
  10.  
  11. implementation
  12.  
  13. var
  14.    TimerTicking : boolean;
  15.    h1, m1, s1, s1001 : word;
  16.  
  17. procedure RestartTimer;
  18. begin
  19.      TimerTicking := true;
  20.      gettime(h1, m1, s1, s1001)
  21. end;
  22.  
  23. function Elapsed:real;
  24.  
  25.          function AbsTime(h,m,s,s100:word):real;
  26.          begin
  27.               AbsTime := (s100/100.0) + s + (60.0*m) + (3600.0*h)
  28.          end;
  29.  
  30. var h2, m2, s2, s1002 : word;
  31.     T1, T2 : real;
  32. begin
  33.      if TimerTicking then
  34.      begin
  35.           gettime(h2, m2, s2, s1002);
  36.           T1 := AbsTime(h1, m1, s1, s1001);
  37.           T2 := AbsTime(h2, m2, s2, s1002);
  38.           Elapsed := T2 - T1
  39.      end
  40.      else
  41.          Elapsed := 0.0
  42. end;
  43.  
  44. function ElapsedStr:string;
  45. var s:string;
  46. begin
  47.      str(Elapsed:6:1,s);
  48.      ElapsedStr := 't = '+s+'s.  '
  49. end;
  50.  
  51. begin
  52.      TimerTicking := false
  53. end.
  54.