[comp.lang.pascal] Keyboard Input

dhesi@bsu-cs.bsu.edu (Rahul Dhesi) (07/21/89)

In article <538@winnie.fit.edu> acs60222@zach.UUCP ( ENRIQUEZ) writes:
>
>I have a simple question regarding keyboard input.  Is is possible to
>trap the input (i.e. single character) using a routine such as 
>
>   readln (kbd,char);
>
>in Pascal.
>
>I am tired of getting a bad character AND a \n character when checking
>for valid user input.  Also, I don't like having to hit <return> :-(
>
>Thanks.... mark enriquez (acs60222@zach.UUCP)

I am quoting the entire article and directing follow-ups to
comp.lang.pascal.

There may be some shortcomings in your Pascal compiler and/or its
documentation.

The '\n' character is not defined in Pascal.  Let's assume by this you
mean 'newline'.  However, 'readln' in pascal cannot ever return a
newline.  It returns a blank if you do attempt to read a newline
character.

Having to hit 'return' is necessary if you want to edit a
partially-typed line.  Single-character input is probably possible but
a very system-dependent thing.   You will have to tell the terminal
driver to do single-character input, and once you have done so, you
should use 'read' (which can indeed read a single character) rather
than 'readln' (which always scans for and skips past a newline
following anything just read).
-- 
Rahul Dhesi <dhesi@bsu-cs.bsu.edu>
UUCP:    ...!{iuvax,pur-ee}!bsu-cs!dhesi