home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
C!T ROM 2
/
ctrom_ii_b.zip
/
ctrom_ii_b
/
PROGRAM
/
PASCAL
/
PARADIS1
/
TIMER.PAS
< prev
next >
Wrap
Pascal/Delphi Source File
|
1991-01-30
|
3KB
|
114 lines
(10689) Sat 25 Jan 92 14:42
By: Chris Barrett
To: Michael Mikelas
Re: Internal timer for door
St:
---------------------------------------------------------------------------
@EID:cc0a 18397540
@MSGID: 3:690/626.6 2981c04c
@REPLY: 1:129/150.0 297ad3e2
On <Jan 20 08:51>, Michael Mikelas (1:129/150) writes:
Hi Michael,
MM>I'm writing a BBS door and have passed the user's time remaining into the
MM>program via a parameter string...how do I go about setting up an internal
MM>timer that will exit the program if the user's time expires? BTW: I'm
MM>using TP 6.0 if that makes a difference...
Here's a unit I wrote... After the unit is a sample of how I would use it in
your program..
(*---------------------------*)
Unit Timer;
(* Written by Chris Barrett (3:690/626.6) *)
(* Released to the Pubic Domain *)
Interface
Procedure StartTimer(Time : Word);
Procedure Uninstall_Timer;
Var
TimeUp : Boolean;
Implementation
Uses
DOS;
Var
RealInt1C : Pointer;
Ticks : Longint;
Sec : Word;
Procedure _Timer;
Begin
Inc(Ticks);
If Ticks mod 18 = 0 then Dec(Sec);
If Sec = 0 then TimeUp := True;
End;
Procedure FakeInt1C;
Interrupt;
Begin
_Timer;
Inline($9C/$FF/$1E/RealInt1C);
End;
Procedure Install;
Begin
GetIntVec($1C,RealInt1C);
SetIntVec($1C,@FakeInt1C);
End;
Procedure Uninstall_Timer;
Begin
SetIntVec($1C,RealInt1C);
End;
Procedure StartTimer(Time : Word);
Begin
Sec := Time;
TimeUp := False;
End;
Begin
Install;
End.
(*----------------------------*)
Put the line "Uses Timer;" at the top of your program.
When you want to start the timer with say 'x' seconds remaining call the
procedure 'StartTimer' like this "StartTimer(x);" Once the 'x' seconds have
expired a boolean flag called 'TimeUp' will be set to True (normally it's set
to false).
If TImeUp is true it wont automatically exit the program. You'll have to check
if TimeUp is true and then act on it.
Repeat
{ your code }
Until TimeUp;
Writeln('Sorry your time is up. Now returning you to the BBS');
At the very end of your program call the 'Uninstall_Timer' procedure.
Note : Multiple calls to StartTimer will just set a new countdown. Multiple
timers are not catered for.
I hope this does what you want. If you need any help fell free to yell.
Seeya,
Chris.
--- Msged/sq
* Origin: Wanted : An original originline! (3:690/626.6)
@PATH: 6260/6 690/626 601 644 640/821 124/4115 5125 396/5 1
@PATH: 170/400 512/0 1007