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
|