home *** CD-ROM | disk | FTP | other *** search
/ The Fred Fish Collection 1.5 / ffcollection-1-5-1992-11.iso / ff_disks / 300-399 / ff339.lzh / PCQ / Examples / TimerTest.p < prev    next >
Text File  |  1990-03-19  |  867b  |  36 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/Ports.i"}
  9. {$I ":Include/ExecIO.i"}
  10. {$I ":Include/TimerDevice.i"}
  11. {$I ":Include/TimerUtils.i"}
  12.  
  13. var
  14.     T : TimerRequestPtr;
  15.     StartTime,
  16.     EndTime : TimeVal;
  17.  
  18. begin
  19.     T := CreateTimer;
  20.     if T <> Nil then begin
  21.     GetSysTime(T, StartTime);
  22.     Writeln('Started at ', Float(StartTime.tvSecs and $FFFF) +
  23.                 (Float(StartTime.tvMicro) / 1000000.0):0:8);
  24.     Writeln('Wait about 4 seconds....');
  25.     WaitTimer(T, 4, 0);
  26.     GetSysTime(T, EndTime);
  27.     Writeln('Ended at   ', Float(EndTime.tvSecs and $FFFF) + 
  28.                 (Float(EndTime.tvMicro) / 1000000.0):0:8);
  29.     SubTime(EndTime, StartTime);
  30.     Writeln('Difference: ', Float(EndTime.tvSecs and $FFFF) +
  31.                 Float(EndTime.tvMicro) / 1000000.0:0:8);
  32.     DeleteTimer(T);
  33.     end else
  34.     Writeln('Could not open timer.');
  35. end.
  36.