From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-0.8 required=5.0 tests=BAYES_00,INVALID_DATE autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,31779cbaecd58cf9 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 1994-10-15 22:08:42 PST Path: bga.com!news.sprintlink.net!howland.reston.ans.net!pipex!uunet!demos1!glas!demos1!sei.cmu.e!ajpo.sei.cmu.edu!riehler From: riehler@ajpo.sei.cmu.edu Newsgroups: comp.lang.ada Date: 14 Oct 94 22:36 GMT+0300 Subject: Re: HELP Message-ID: <1994Oct14.153635.21453@sei.cmu.e> References: Sender: Notesfile to Usenet Gateway Date: 1994-10-14T22:36:00+00:00 List-Id: In article chhung2@cuse1.se.cuhk.hk (Chiu Bo (Hung Chiu Hung)) writes: >Could any body tell me how to detect keyboard input without waiting for >the carrier return. > >thanx... > > Good Question. The answer varies by operating system. If you need to do this, write a package specification to abstract the operations away from the compiler and the operating system. package KeyBoard_Handler is function KeyBoard_Ready return Boolean; -- other operations end KeyBoard_Handler; In MS-DOS, you will find there are several interrupts you can trap to determine keyboard status. If you pragma interface to assembler, you can use Interupt 33 (hex 21), Function 11 (hex B) to implement this. An easier approach is to use the DOS Environments provided by the compiler vendors. Janus (the underlying compiler for InegrAda), Meridian, and Alsys, all have DOS Environments. One approach is to use the Interrupt Handling package. This is overly difficult for most new programmers. Consider: Meridian: package TTY function Char_Ready return Boolean; (INT 16H, Function 01H) Alsys: package DOS function KBD_Data_Available return Boolean; Janus: package (varies by compiler) function Keypress return Boolean; I find this is one of the useful places to use an Ada task under MS-DOS. You can design a select statement to trap keyboard input as an external "event", buffer the characters with another task, and keep the rest of your system rolling along without a burp. It also works well in commandf and control systems where one needs to keep the display functioning with constant updates while receiving data from the keyboard. There are UNIX solutions to this, as well, but they also vary by compiler. This would have been a good function to include in Ada 9X Text_IO, but it's too late now. The good news is that your Keyboard_Handler can be child of Ada.Text_IO. IN fact, Janus has done just that with an Extensions package: Ada.Text_IO.Extensions.Keypress ... I have a rather long example of this I can send to anyone who wants to see how it works, but it is too long to post. (Hung Xiansheng, dong bu dong?) Richard Riehle AdaWorks Software Engineering Suite 27 2555 Park Boulevard Palo Alto, CA 94306 (415) 328-1815 FAX 328-1112 email: adaworks@netcom.com