home *** CD-ROM | disk | FTP | other *** search
/ AMIGA PD 1 / AMIGA-PD-1.iso / Programme_zum_Heft / Programmieren / Kurztests / PascalPCQ / Examples / TimerTest.p < prev    next >
Text File  |  1990-07-20  |  829b  |  34 lines

  1. Program TimerTest;
  2.  
  3. {
  4.     A very simple example of using the timer.device and its
  5.     support functions.
  6. }
  7.  
  8. {$I "Include:Devices/Timer.i"}
  9. {$I "Include:Utils/TimerUtils.i"}
  10.  
  11. var
  12.     T : TimeRequestPtr;
  13.     StartTime,
  14.     EndTime : TimeVal;
  15.  
  16. begin
  17.     T := CreateTimer;
  18.     if T <> Nil then begin
  19.     GetSysTime(T, StartTime);
  20.     Writeln('Started at ', Float(StartTime.tv_Secs and $FFFF) +
  21.                 (Float(StartTime.tv_Micro) / 1000000.0):0:8);
  22.     Writeln('Wait about 4 seconds....');
  23.     WaitTimer(T, 4, 0);
  24.     GetSysTime(T, EndTime);
  25.     Writeln('Ended at   ', Float(EndTime.tv_Secs and $FFFF) + 
  26.                 (Float(EndTime.tv_Micro) / 1000000.0):0:8);
  27.     SubTime(EndTime, StartTime);
  28.     Writeln('Difference: ', Float(EndTime.tv_Secs and $FFFF) +
  29.                 Float(EndTime.tv_Micro) / 1000000.0:0:8);
  30.     DeleteTimer(T);
  31.     end else
  32.     Writeln('Could not open timer.');
  33. end.
  34.