Xref: utzoo comp.lang.c:20061 comp.lang.pascal:2105 Path: utzoo!utgpu!jarvis.csri.toronto.edu!rutgers!iuvax!bsu-cs!dhesi From: dhesi@bsu-cs.bsu.edu (Rahul Dhesi) Newsgroups: comp.lang.c,comp.lang.pascal Subject: Re: Keyboard Input Keywords: Keyboard , Input , Trapping Message-ID: <8340@bsu-cs.bsu.edu> Date: 21 Jul 89 01:24:00 GMT References: <20283@adm.BRL.MIL> <10557@smoke.BRL.MIL> <538@winnie.fit.edu> Reply-To: dhesi@bsu-cs.bsu.edu (Rahul Dhesi) Followup-To: comp.lang.pascal Organization: CS Dept, Ball St U, Muncie, Indiana Lines: 35 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 :-( > >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 UUCP: ...!{iuvax,pur-ee}!bsu-cs!dhesi