comp.lang.ada
 help / color / mirror / Atom feed
From: riehler@ajpo.sei.cmu.edu
Subject: Re: HELP
Date: 14 Oct 94 22:36 GMT+0300
Date: 1994-10-14T22:36:00+00:00	[thread overview]
Message-ID: <1994Oct14.153635.21453@sei.cmu.e> (raw)
In-Reply-To: Cxn8J2.HxJ@eng_ser1.erg.cuhk.hk

In article <Cxn8J2.HxJ@eng_ser1.erg.cuhk.hk> 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







  parent reply	other threads:[~1994-10-14 19:36 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1994-10-14  3:33 HELP Chiu Bo (Hung Chiu Hung)
1994-10-14 13:21 ` HELP Robert Dewar
1994-10-15 14:56   ` HELP Bob Duff
1994-10-18 16:31     ` HELP Robert Dewar
1994-10-16  5:11   ` HELP Chiu Bo (Hung Chiu Hung)
1994-10-14 19:36 ` riehler [this message]
1994-10-14 19:36 ` HELP Richard Riehle
1994-10-19  3:10 ` HELP Michael M. Bishop
  -- strict thread matches above, loose matches on Subject: below --
2001-09-19 19:51 help mop
2001-09-20  8:41 ` help John McCabe
1998-12-07  0:00 help Salvador
1998-12-07  0:00 ` help dennison
1997-02-27  0:00 Help Desperate
1997-03-04  0:00 ` Help Jim Dorman
1996-11-15  0:00 Help Alexander B. Schmidt
1996-11-15  0:00 ` Help Michael Paus
1996-11-18  0:00 ` Help Norman H. Cohen
1996-11-19  0:00 ` Help Matthew Heaney
1994-10-19 16:26 HELP CONDIC
1993-03-12 22:28 Help Basavaraj B Patil
1990-08-01 18:19 Help Kenneth Anderson
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox