Article View: comp.lang.pascal.borland
Article #739Re: Hooking an Interupt
From: Ing. Franz Glaser
Date: Mon, 26 Oct 1998 00:00
Date: Mon, 26 Oct 1998 00:00
69 lines
2837 bytes
2837 bytes
Wilmot wrote:
>
> I want to have something on the screen the whole time a program is running,
> and I am told I do this by hooking and interrupt. I have looked at some
> sample code of this type of stuff but have no idea how to get it working. If
> anyone could help it would be great.
No, not with an Interrupt! Assuming that you do not speak about a
Windows program:
make an "idle" procedure, which does the display job from a mailbox
variable. The mailbox variable must be defined in a very first unit,
as well as the idle procedure.
Unit Definitions; {shall be "used" as the first unit in your main prog.}
Interface
Var RemainingAmount : Real;
.... more "global" variables
Implememntation
End.
Unit IdleUnit;
Uses CRT,Definitions;
Interface
Procedure Idle;
Implementation
Procedure Idle;
Var OldX, OldY, OldTA : Integer;
Begin
OldX := WhereX; OldY := WhereY; OldTA := TextAttr;
GotoXY(....,....); TextAttr := $1E;
Write(RemainingAmount:10:2);
GotoXY(OldX,OldY); TextAttr := OldTA;
End;
End.
Unit KeyIO;
Interface
Uses CRT,IdleUnit;
Procedure GetKey : Word;
Implementation
Procedure GetKey : Word;
Var Ch : Char;
Begin
While not KeyPressed do
Idle;
Ch := ReadKey;
if Ch = #0 then
GetKey := Ord(ReadKey) shl 8 {function and arrow keys are $xx00}
else
GetKey := Ord(Ch); {normal chars are $00xx}
End;
End.
Now you use GetKey wherever you would use readkey in your program,
converting
the word to a char if applicable:
TC := GetKey;
case TC of
0..255 : ...
$2100 : upkey; { $2100 is not correct, I do not remember}
end;
Also I suggest you consider Turbo Vision, it has all the features
built in! Article "Why TP programmers should consider TV programming"
in the FAQ chapter of the TP-links site:
http://www.geocities.com/SiliconValley/2926/tp.html
Regards, Franz Glaser
Technical Details
Message-ID:
<36345AAF.C1BF13DC@eunet.at>Path:
arc1-ca.pugleaf.net!unknown!not-for-mailReferences:
<711kpl$9jm$1@bunyip.cc.uq.edu.au>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 111659,93b94cc331b669a1 X-Google-Attributes: gid111659,public X-Google-Thread: 10261c,93b94cc331b669a1 X-Google-Attributes: gid10261c,public X-Google-Thread: 108d84,93b94cc331b669a1 X-Google-Attributes: gid108d84,public From: "Ing. Franz Glaser" <meg-glaser@eunet.at> Subject: Re: Hooking an Interupt Date: 1998/10/26 Message-ID: <36345AAF.C1BF13DC@eunet.at> X-Deja-AN: 405148075 Content-Transfer-Encoding: 7bit References: <711kpl$9jm$1@bunyip.cc.uq.edu.au> To: Wilmot <extremists@cryogen.com> Content-Type: text/plain; charset=us-ascii X-Complaints-To: abuse@Austria.EU.net X-Trace: fleetstreet.Austria.EU.net 909400762 1563 193.81.169.182 (26 Oct 1998 11:19:22 GMT) Organization: Customer of EUnet Austria Mime-Version: 1.0 NNTP-Posting-Date: 26 Oct 1998 11:19:22 GMT Newsgroups: comp.lang.pascal.borland,comp.lang.pascal.misc,fidonet.pascal