home *** CD-ROM | disk | FTP | other *** search
- (* TBTree13 Copyright (c) 1988 Dean H. Farwell II *)
-
- unit Time;
-
- (*****************************************************************************)
- (* *)
- (* T I M E R O U T I N E S *)
- (* *)
- (*****************************************************************************)
-
-
- (* Procedures to support time in Turbo Pascal. These procedures do not use
- BIOS or DOS calls, but access RAM directly to get time information. *)
-
- (* Version Information
-
- Version 1.1 - No Changes
-
- Version 1.2 - No Changes
-
- Version 1.3 - No Changes *)
-
- (*\*)
- (*////////////////////////// I N T E R F A C E //////////////////////////////*)
-
- interface
-
- uses
- Compare,
- Numbers;
-
- type
- TimeArr = Array[1 .. 4] of Byte; (* store the 4 bytes from RAM which
- holds the present time *)
-
-
- (* Get the 4 byte time from RAM and place it into the 4 byte array x *)
-
- procedure GetTime(var x : TimeArr);
-
-
- (* This function compares two time arrays. LESSTHAN is returned if X is less
- than Y (earlier). GREATERTHAN is returned if X is greater than Y (later).
- If they are equal then EQUALTO is returned *)
-
- function CompareTime(x : TimeArr;
- y : TimeArr) : Comparison;
-
-
- (* This routine prints out the 4 byte time array *)
-
- procedure PrintTime(x : TimeArr);
-
-
- (* This routine sets each byte of the time array to 255 (all bits = 1) *)
-
- procedure SetMaxTime(var x : TimeArr);
-
- (*\*)
- (*///////////////////// I M P L E M E N T A T I O N /////////////////////////*)
-
- implementation
-
-
- (* Get the 4 byte time from RAM and place it into the 4 byte array x *)
-
- procedure GetTime(var x : TimeArr);
-
- var
- time : TimeArr absolute $0000 : $046C;
- cnt : 1 .. 4;
-
- begin
- for cnt := 1 to 4 do
- begin
- x[cnt] := time[cnt];
- end;
- end; (* End of GetTime Procedure *)
-
- (*\*)
- (* This function compares two time arrays. LESSTHAN is returned if X is less
- than Y (earlier). GREATERTHAN is returned if X is greater than Y (later).
- If they are equal then EQUALTO is returned *)
-
- function CompareTime(x : TimeArr;
- y : TimeArr) : Comparison;
-
- var
- cnt : 0 .. 4;
- done : boolean;
-
- begin
- cnt := 4;
- done := false;
- while not done do
- begin
- if x[cnt] < y[cnt] then
- begin
- done := true;
- CompareTime := LESSTHAN;
- end
- else
- begin
- if x[cnt] > y[cnt] then
- begin
- done := true;
- CompareTime := GREATERTHAN;
- end
- else
- begin
- cnt := cnt - 1;
- if cnt = 0 then
- begin
- done := true;
- CompareTime := EQUALTO;
- end;
- end;
- end;
- end;
- end; (* end of CompareTime routine *)
-
-
- (* This routine prints out the 4 byte time array *)
-
- procedure PrintTime(x : TimeArr);
-
- begin
- Writeln(x[1]:4,x[2]:4,x[3]:4,x[4]:4);
- end; (* end of PrintTime routine *)
-
-
- (* This routine sets each byte of the time array to 255 (all bits = 1) *)
-
- procedure SetMaxTime(var x : TimeArr);
-
- var
- cnt : 1 .. 4;
-
- begin
- for cnt := 1 to 4 do
- begin
- x[cnt] := MAXBYTE;
- end;
- end; (* end of SetMaxTime routine *)
-
- end. (* end of Time unit *)