Category : Modula II Source Code
Archive   : M2-LIB2.ZIP
Filename : PMPTIMER.MOD

 
Output of file : PMPTIMER.MOD contained in archive : M2-LIB2.ZIP
(*====================================================================
= Program Id: PMPTIMER.MOD =
= Programmer: Peter M. Perchansky =
= Purpose: Export timing procedures. =
= Date Written: 12-16-89 =
====================================================================*)

IMPLEMENTATION MODULE PMPTimer;

FROM PMPDos IMPORT DayType, GetDate, GetTime;

TYPE
TimeRec = RECORD
day : CARDINAL;
time : LONGCARD;
END;

VAR
tick [40H:108] : LONGCARD;
(* number of ticks (18.2 times per second) since midnight *)

tickInstall : LONGCARD;
(* timer tick at installation *)

timeInstall : TimeRec;
(* time of installation using StartTimer *)

PROCEDURE StartTimer ();
(* Saves current day and time value in timeInstall *)

VAR
hrs, min, sec, hsec : CARDINAL;
day, month, year : CARDINAL;
hsecValue : LONGCARD;
dayType : DayType;

BEGIN
GetDate (day, month, year, dayType);
GetTime (hrs, min, sec, hsec);

timeInstall.day := day;
hsecValue := (LONGCARD (hrs) * 360000) + (LONGCARD (min) * 6000)
+ (LONGCARD (sec) * 100) + LONGCARD (hsec);

timeInstall.time := hsecValue;
END StartTimer;

PROCEDURE ElapsedTime () : LONGCARD;
(* Returns elapsed time from call to StartTimer to *)
(* current time. Elapsed time is in hundredths of *)
(* a second. *)

VAR
day, month, year : CARDINAL;
hrs, min, sec, hsec : CARDINAL;
hsecValue : LONGCARD;
dayType : DayType;

BEGIN
GetTime (hrs, min, sec, hsec);
GetDate (day, month, year, dayType);

IF day > timeInstall.day THEN
INC (hrs, 23) (* hrs go from 0..23 *)
END;

hsecValue := (LONGCARD (hrs) * 360000) + (LONGCARD (min) * 6000)
+ (LONGCARD (sec) * 100) + LONGCARD (hsec);

RETURN (hsecValue - timeInstall.time);
END ElapsedTime;

PROCEDURE StartTick ();
(* Saves number of ticks at time of installation. *)

BEGIN
tickInstall := tick;
END StartTick;

PROCEDURE ElapsedTicks (): LONGCARD;
(* Returns elapsed time from call of StartTick to *)
(* current tick value. Elapsed time is in seconds. *)

BEGIN
RETURN (LONGCARD (FLOAT (ABS (tick - tickInstall)) / 18.20));
END ElapsedTicks;

END PMPTimer.


  3 Responses to “Category : Modula II Source Code
Archive   : M2-LIB2.ZIP
Filename : PMPTIMER.MOD

  1. Very nice! Thank you for this wonderful archive. I wonder why I found it only now. Long live the BBS file archives!

  2. This is so awesome! 😀 I’d be cool if you could download an entire archive of this at once, though.

  3. But one thing that puzzles me is the “mtswslnkmcjklsdlsbdmMICROSOFT” string. There is an article about it here. It is definitely worth a read: http://www.os2museum.com/wp/mtswslnk/