[comp.lang.pascal] Readkey alternative?

fer9483@tesla.njit.edu (04/22/91)

I am writing a door for a friends BBS.. everything is fine except for one
thing, the output doesn't work if i include the CRT unit..  this is
not on my end, but on the BBS's and the way it handles output.. now this
is all fine and dandy except for i need a function like readkey without
using the crt unit.. just something that gets a key without waiting for
a carriage return..

Any help?

                                  Frank

ts@uwasa.fi (Timo Salmi) (04/23/91)

In article <1991Apr22.114908.1@tesla.njit.edu> fer9483@tesla.njit.edu writes:
:
>is all fine and dandy except for i need a function like readkey without
>using the crt unit.. just something that gets a key without waiting for
>a carriage return..
:

If you have access to our archives, the /pc/ts/tspa23## (##=40 50 55
60) units include such goods.  There is no source code included or
available (sorry). 

...................................................................
Prof. Timo Salmi
Moderating at garbo.uwasa.fi anonymous ftp archives 128.214.12.37
School of Business Studies, University of Vaasa, SF-65101, Finland
Internet: ts@chyde.uwasa.fi Funet: gado::salmi Bitnet: salmi@finfun

Kai_Henningsen@ms.maus.de (Kai Henningsen) (04/27/91)

fer9483 @ tesla.njit.edu schrieb am 22.04.1991, 13:49

fe>I am writing a door for a friends BBS.. everything is fine except for one
fe>thing, the output doesn't work if i include the CRT unit..  this is
fe>not on my end, but on the BBS's and the way it handles output.. now this
fe>is all fine and dandy except for i need a function like readkey without
fe>using the crt unit.. just something that gets a key without waiting for
fe>a carriage return..

Well, I won't start explaining the old Crt-rewrite('')-problem, as that
wouldn't solve your problem; I'll only say that readkey works ONLY with the
keyboard.

There are several ways to work with the serial port instead; however, if you
want to use normal DOS redirection (which, from your description, I assume),
then the obvious solution seems to be using the DOS character I/O functions.

There are several; you might try each to determine which works best for you:

AH=01 -> AL=char        Character input with echo     ^C works
AH=06 DL=FF -> AL=char  Direct console I/O            ^C is normal char
AH=07 -> AL=char        Unfiltered character input without echo
                                                      ^C is normal char
AH=08 -> AL=char        Character input without echo  ^C works

You might also consider, for a replacement to keypress,
AH=0b -> AL=00/FF       Check input status            ^C works

For an example of how to use these:

uses DOS;
function ReadKeyDOS: char;
var r: registers;
begin
  r.ah:=$07;
  msdos(r);
  ReadKeyDOS:=chr(r.al);
end;

I'm not sure, but I believe ^C recognition can be disabled completely by
putting the input device into "raw" mode via an ioctl. If you need that, ask
again, and I'll look it up.

MfG Kai