TIP: Click on subject to list as thread! ANSI
echo: pascal
to: MICHEL VAN DER HEIJDEN
from: KIM FORWOOD
date: 1998-04-16 13:21:00
subject: Re: Keybord input

Michel van der Heijden wrote: 
 MvdH> I've got a loop which has to do some checking and presenting a klok on
 MvdH> te screen. No problems with that but i want to put some keybord input
 MvdH> in this loop also and then i've got a problem. The loop doesn't go
 MvdH> further u til a key is pressed and that's something i don't want. It
 MvdH> must run it's loop like normal but it must be possible to enter a key
 MvdH> also. Anybody an idea how i can accomplish this? 
The best way is to hook the timer interrupt. Here's a clock unit I use:
UNIT Clock;
INTERFACE
{$A-,B-,D-,E-,F+,G+,I-,L-,N-,O-,P-,Q-,R-,S-,T-,V-,X-}
   PROCEDURE InitClock(Xclk,Yclk: byte);
   PROCEDURE DoneClock;
IMPLEMENTATION
uses Dos, Screen;
var
   SavedExit          : pointer;
   OldTimer           : procedure;
   Hour,Minute,Second : longint;
   TimerTick          : word;
   VidSeg             : word;
   X,Y                : byte;
{============================================================================}
 PROCEDURE WriteXY(X,Y: byte; Ch: char);
{----------------------------------------------------------------------------}
begin
   Mem[VidSeg:160*(Y-1)+2*(X-1)] := Ord(Ch);
end; { WriteXY }
{==========================================================================}
 PROCEDURE ShowTime(Flags,CS,IP,AX,BX,CX,DX,SI,DI,DS,ES,BP: word); interrupt;
{--------------------------------------------------------------------------}
begin
   Inc(TimerTick);
   if TimerTick = 18 then begin
      TimerTick := 0;
      Hour   := MemW[$0040:$006E] mod 24;
      Minute := MemW[$0040:$006C];
      Minute := ((Minute * 5) div 5461) mod 60;
      Second := MemW[$0040:$006C];
      Second := ((Second * 5) div 91) mod 60;
      WriteXY(X+0,Y,Chr(48 + Hour div 10));
      WriteXY(X+1,Y,Chr(48 + Hour mod 10));
      WriteXY(X+2,Y,':');
      WriteXY(X+3,Y,Chr(48 + Minute div 10));
      WriteXY(X+4,Y,Chr(48 + Minute mod 10));
      WriteXY(X+5,Y,':');
      WriteXY(X+6,Y,Chr(48 + Second div 10));
      WriteXY(X+7,Y,Chr(48 + Second mod 10));
   end;
end;
{==========================================================================}
 PROCEDURE InitClock(Xclk,Yclk: byte);
{--------------------------------------------------------------------------}
begin
   X := Xclk;
   Y := Yclk;
   TimerTick := 0;
   if Mem[$0000:$0449] = 7 then VidSeg := $B000
   else VidSeg := $B800;
   GetIntVec($1C,@OldTimer);
   SetIntVec($1C,@ShowTime);
end;
{==========================================================================}
 PROCEDURE DoneClock;
{--------------------------------------------------------------------------}
begin
   ExitProc := SavedExit;
   SetIntVec($1C,@OldTimer);
end;
BEGIN
   SavedExit := ExitProc;
   ExitProc  := @DoneClock;
END.
  Kim Forwood
---------------------------------------
 Internet: kim.forwood@elab.canbbs.net
  FidoNet: Kim Forwood, 1:153/831
---------------------------------------
--- Blue Wave/DOS v?.??
---------------
* Origin: The Eclectic Lab (1:153/831)

SOURCE: echomail via exec-pc

Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.