comp.lang.ada
 help / color / mirror / Atom feed
* How do I make HOTKEYS in ADA?
@ 1996-10-05  0:00 Randy Kosarik
  1996-10-07  0:00 ` Tucker Taft
  1996-10-08  0:00 ` Jon S Anthony
  0 siblings, 2 replies; 11+ messages in thread
From: Randy Kosarik @ 1996-10-05  0:00 UTC (permalink / raw)



Hi all,

	I need to know if I can get ADA to scan the keyboard and return the
ASCII value if a keystroke was made. This also cannot stop the execution
of the program and wait for <ENTER>.

	I have a project in my Software Engineering class and am learning ADA
on the fly. 

  Thanks in advance to any/all that gives advice on this!!! 

-Randy




^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: How do I make HOTKEYS in ADA?
  1996-10-05  0:00 How do I make HOTKEYS in ADA? Randy Kosarik
@ 1996-10-07  0:00 ` Tucker Taft
  1996-10-08  0:00 ` Jon S Anthony
  1 sibling, 0 replies; 11+ messages in thread
From: Tucker Taft @ 1996-10-07  0:00 UTC (permalink / raw)



Randy Kosarik (randyk@access.hky.com) wrote:

: 	I need to know if I can get ADA to scan the keyboard and return the
: ASCII value if a keystroke was made. This also cannot stop the execution
: of the program and wait for <ENTER>.

The "Get_Immediate" procedure in the Ada 95 Ada.Text_IO is designed to provide
this, though it is still implementation-dependent whether on any
given operating system, this capability is/can be supported.

For Ada 83, or Ada 95 systems where Get_Immediate does not provide
the desired functionality, you should be able to use pragma Interface 
(Ada 83) or pragma Import (Ada 95) to connect up to the appropriate 
underlying system call.  Alternatively, your compiler may already
come with a means of accessing this underlying operating system
capability.

: 	I have a project in my Software Engineering class and am learning ADA
: on the fly. 

:   Thanks in advance to any/all that gives advice on this!!! 

If you could specify the compiler and the hardware/OS platform, we
could probably provide more help.  You should also consult whatever
literature is available on the compiler you are using, especially if
it is an Ada 83 compiler.  For Ada 95, Ada.Text_IO.Get_Immediate should
do the trick, if the underlying O/S supports it.

: -Randy

-Tucker Taft   stt@inmet.com   http://www.inmet.com/~stt/
Intermetrics, Inc.  Cambridge, MA  USA




^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: How do I make HOTKEYS in ADA?
  1996-10-05  0:00 How do I make HOTKEYS in ADA? Randy Kosarik
  1996-10-07  0:00 ` Tucker Taft
@ 1996-10-08  0:00 ` Jon S Anthony
  1996-10-10  0:00   ` Keith Thompson
                     ` (3 more replies)
  1 sibling, 4 replies; 11+ messages in thread
From: Jon S Anthony @ 1996-10-08  0:00 UTC (permalink / raw)



In article <3256B8C7.18F9@access.hky.com> Randy Kosarik <randyk@access.hky.com> writes:

> 	I need to know if I can get ADA to scan the keyboard and return the
> ASCII value if a keystroke was made.

Look up Get_Immediate.


> This also cannot stop the execution
> of the program and wait for <ENTER>.

You will need to use tasks or ATC for this.

> 	I have a project in my Software Engineering class and am learning ADA
> on the fly. 

A recipie for disaster?


/Jon
-- 
Jon Anthony
Organon Motives, Inc.
1 Williston Road, Suite 4
Belmont, MA 02178

617.484.3383
jsa@organon.com





^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: How do I make HOTKEYS in ADA?
  1996-10-08  0:00 ` Jon S Anthony
@ 1996-10-10  0:00   ` Keith Thompson
  1996-10-10  0:00     ` Larry Kilgallen
  1996-10-11  0:00   ` Jon S Anthony
                     ` (2 subsequent siblings)
  3 siblings, 1 reply; 11+ messages in thread
From: Keith Thompson @ 1996-10-10  0:00 UTC (permalink / raw)



In <JSA.96Oct8161800@alexandria> jsa@alexandria (Jon S Anthony) writes:
> In article <3256B8C7.18F9@access.hky.com> Randy Kosarik <randyk@access.hky.com> writes:
> > 	I need to know if I can get ADA to scan the keyboard and return the
> > ASCII value if a keystroke was made.
> Look up Get_Immediate.
> > This also cannot stop the execution
> > of the program and wait for <ENTER>.
> You will need to use tasks or ATC for this.

Not necessarily.  There's a form of Get_Immediate that returns immediately
if no character is available for input.  Whether this is implemented
"properly" is another question.  (I put "properly" in quotes because
there's some question about what the language really requires; the
expected behavior, though, is pretty clearly what you're looking for.)

It's also implementation-defined whether the typed character will
be echoed.

-- 
Keith Thompson (The_Other_Keith) kst@thomsoft.com <*>
TeleSoft^H^H^H^H^H^H^H^H Alsys^H^H^H^H^H Thomson Software Products
10251 Vista Sorrento Parkway, Suite 300, San Diego, CA, USA, 92121-2706
FIJAGDWOL




^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: How do I make HOTKEYS in ADA?
  1996-10-10  0:00   ` Keith Thompson
@ 1996-10-10  0:00     ` Larry Kilgallen
  1996-10-11  0:00       ` Randy Kosarik
  1996-10-11  0:00       ` Robert Dewar
  0 siblings, 2 replies; 11+ messages in thread
From: Larry Kilgallen @ 1996-10-10  0:00 UTC (permalink / raw)



In article <Dz24vt.1ox@thomsoft.com>, kst@thomsoft.com (Keith Thompson) writes:
> In <JSA.96Oct8161800@alexandria> jsa@alexandria (Jon S Anthony) writes:
>> In article <3256B8C7.18F9@access.hky.com> Randy Kosarik <randyk@access.hky.com> writes:
>> > 	I need to know if I can get ADA to scan the keyboard and return the
>> > ASCII value if a keystroke was made.
>> Look up Get_Immediate.
>> > This also cannot stop the execution
>> > of the program and wait for <ENTER>.
>> You will need to use tasks or ATC for this.
> 
> Not necessarily.  There's a form of Get_Immediate that returns immediately
> if no character is available for input.  Whether this is implemented
> "properly" is another question.  (I put "properly" in quotes because
> there's some question about what the language really requires; the
> expected behavior, though, is pretty clearly what you're looking for.)
> 
> It's also implementation-defined whether the typed character will
> be echoed.

I would presume it is also implementation-defined (or environment-defined)
as to _when_ any such echo will take place, since some older operating
systems echo characters when they are typed rather than when they are
read (confusing confident typists enormously, but presumably benefiting
those who are unsure about what they keyed).

Larry Kilgallen




^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: How do I make HOTKEYS in ADA?
  1996-10-10  0:00     ` Larry Kilgallen
@ 1996-10-11  0:00       ` Randy Kosarik
  1996-10-15  0:00         ` John Herro
  1996-10-11  0:00       ` Robert Dewar
  1 sibling, 1 reply; 11+ messages in thread
From: Randy Kosarik @ 1996-10-11  0:00 UTC (permalink / raw)



Larry,

	My NEWSSERVER must of had some problems, I did not see some of the
replies. Although, I did get one reply back via Email which mentioned
the Text_IO.Get_Immediate() statement. I had a problem with it though
because I am required to use the schools VAX with DEC Ada 3.2-8 (Ada 83
complient). 
	You brought up an interesting point that I was not considering though,
the echoing of the input characters. I am going to have to control them
also. Any ideas are still welcome..

	Thanks to all for discussing this topic!! 

-Randy Kosarik


Larry Kilgallen wrote:
> 
> In article <Dz24vt.1ox@thomsoft.com>, kst@thomsoft.com (Keith Thompson) writes:
> > In <JSA.96Oct8161800@alexandria> jsa@alexandria (Jon S Anthony) writes:
> >> In article <3256B8C7.18F9@access.hky.com> Randy Kosarik <randyk@access.hky.com> writes:
> >> >    I need to know if I can get ADA to scan the keyboard and return the
> >> > ASCII value if a keystroke was made.
> >> Look up Get_Immediate.
> >> > This also cannot stop the execution
> >> > of the program and wait for <ENTER>.
> >> You will need to use tasks or ATC for this.
> >
> > Not necessarily.  There's a form of Get_Immediate that returns immediately
> > if no character is available for input.  Whether this is implemented
> > "properly" is another question.  (I put "properly" in quotes because
> > there's some question about what the language really requires; the
> > expected behavior, though, is pretty clearly what you're looking for.)
> >
> > It's also implementation-defined whether the typed character will
> > be echoed.
> 
> I would presume it is also implementation-defined (or environment-defined)
> as to _when_ any such echo will take place, since some older operating
> systems echo characters when they are typed rather than when they are
> read (confusing confident typists enormously, but presumably benefiting
> those who are unsure about what they keyed).
> 
> Larry Kilgallen




^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: How do I make HOTKEYS in ADA?
  1996-10-08  0:00 ` Jon S Anthony
  1996-10-10  0:00   ` Keith Thompson
@ 1996-10-11  0:00   ` Jon S Anthony
  1996-10-14  0:00   ` Norman H. Cohen
  1996-10-16  0:00   ` Jon S Anthony
  3 siblings, 0 replies; 11+ messages in thread
From: Jon S Anthony @ 1996-10-11  0:00 UTC (permalink / raw)



In article <Dz24vt.1ox@thomsoft.com> kst@thomsoft.com (Keith Thompson) writes:

> In <JSA.96Oct8161800@alexandria> jsa@alexandria (Jon S Anthony) writes:
> > In article <3256B8C7.18F9@access.hky.com> Randy Kosarik <randyk@access.hky.com> writes:
> > > 	I need to know if I can get ADA to scan the keyboard and return the
> > > ASCII value if a keystroke was made.
> > Look up Get_Immediate.
> > > This also cannot stop the execution
> > > of the program and wait for <ENTER>.
> > You will need to use tasks or ATC for this.
> 
> Not necessarily.  There's a form of Get_Immediate that returns immediately
> if no character is available for input.  Whether this is implemented
> "properly" is another question.  (I put "properly" in quotes because
> there's some question about what the language really requires; the
> expected behavior, though, is pretty clearly what you're looking for.)

Well, yes, but I didn't read that as acceptable either.  What you are
suggesting is some sort of "loop based scenario".  But this could
cause odd and unacceptable timing skews: check for character.  Nothing
at this moment.  Drop to next part of loop.  Do this work (might take
a while).  Mean time user is hitting key wondering what the #@&% is
wrong.  Finally get back to check for character...

To me, this sort of thing (and its attendent poor program structure)
is unacceptable C style rubbish.

/Jon
-- 
Jon Anthony
Organon Motives, Inc.
Belmont, MA 02178
617.484.3383
jsa@organon.com





^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: How do I make HOTKEYS in ADA?
  1996-10-10  0:00     ` Larry Kilgallen
  1996-10-11  0:00       ` Randy Kosarik
@ 1996-10-11  0:00       ` Robert Dewar
  1 sibling, 0 replies; 11+ messages in thread
From: Robert Dewar @ 1996-10-11  0:00 UTC (permalink / raw)



Larry said

"I would presume it is also implementation-defined (or environment-defined)
as to _when_ any such echo will take place, since some older operating
systems echo characters when they are typed rather than when they are
read (confusing confident typists enormously, but presumably benefiting
those who are unsure about what they keyed)."

Note here that "older operating systems" includes virtually all versions
of Unix, both new and old :-)





^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: How do I make HOTKEYS in ADA?
  1996-10-08  0:00 ` Jon S Anthony
  1996-10-10  0:00   ` Keith Thompson
  1996-10-11  0:00   ` Jon S Anthony
@ 1996-10-14  0:00   ` Norman H. Cohen
  1996-10-16  0:00   ` Jon S Anthony
  3 siblings, 0 replies; 11+ messages in thread
From: Norman H. Cohen @ 1996-10-14  0:00 UTC (permalink / raw)



Jon S Anthony wrote:

> Well, yes, but I didn't read that as acceptable either.  What you are
> suggesting is some sort of "loop based scenario".  But this could
> cause odd and unacceptable timing skews: check for character.  Nothing
> at this moment.  Drop to next part of loop.  Do this work (might take
> a while).  Mean time user is hitting key wondering what the #@&% is
> wrong.  Finally get back to check for character...

Let a separate task poll for key presses.

-- 
Norman H. Cohen
mailto:ncohen@watson.ibm.com
http://www.research.ibm.com/people/n/ncohen




^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: How do I make HOTKEYS in ADA?
  1996-10-11  0:00       ` Randy Kosarik
@ 1996-10-15  0:00         ` John Herro
  0 siblings, 0 replies; 11+ messages in thread
From: John Herro @ 1996-10-15  0:00 UTC (permalink / raw)



Randy Kosarik <randyk@access.hky.com> writes:
> I had a problem with [using Get_Immediate]
> though because I am required to use the
> school's VAX [Ada 83].
     Here's how my Ada Tutor program does the equivalent of Get_Immediate
in VAX Ada 83.  This Get doesn't echo, but you can echo by calling this
Put immediately after Get.  Note that the package has initialization code.
 This is a MESS, sorry, but it works.  I hope it helps.
     For more examples of the equivalent of "Get_Immediate" on various Ada
83 systems, you can download the Ada Tutor program at the Web or FTP site
below my signature.  (The tutorial itself teaches Ada 95, but it's written
in Ada 83, and the source code is included.)
- John Herro
Software Innovations Technology
http://members.aol.com/AdaTutor
ftp://members.aol.com/AdaTutor
-----
package Custom_IO is
   procedure Get(Char : out Character); -- Get_Immediate without echo.
   procedure Put(Char : in  Character);
   procedure Put(Str  : in  String);
end Custom_IO;

with Starlet, System; use Starlet, System;
package body Custom_IO is
   Chan : Starlet.Channel_Type;
   IOSB : System.Unsigned_Quadword;
   Stat : System.Unsigned_Longword;
   procedure QIOW(Stat   : out Unsigned_Longword;
                  EFN    : in Integer;
                  Chan   : in Channel_Type;
                  Func   : in Short_Integer;
                  IOSB   : out Unsigned_Quadword;
                  ASTadr : in Integer;
                  ASTPRM : in Integer;
                  P1     : in out String;
                  P2, P3 : in Integer;
                  P4     : in Unsigned_Quadword;
                  P5, P6 : in Integer);
   pragma Interface(System_Library, QIOW);
   pragma Import_Valued_Procedure(
               Internal => QIOW,
               External => "SYS$QIOW",
               Parameter_Types => (
                    Unsigned_Longword,
                    Integer,
                    Channel_Type,
                    Short_Integer,
                    Unsigned_Quadword,
                    Integer,
                    Integer,
                    String,
                    Integer,
                    Integer,
                    Unsigned_Quadword,
                    Integer,
                    Integer),
               Mechanism => (
                    Value,
                    Value,
                    Value,
                    Value,
                    Reference,
                    Value,
                    Reference,
                    Reference,
                    Value,
                    Reference,
                    Reference,
                    Reference,
                    Reference));

   procedure Get(Char : out Character) is
      S : String(1 .. 1);
   begin
      QIOW(Stat   => Stat,
           EFN    => 0,
           Chan   => Chan,
           Func   => 16#7A#,
           IOSB   => IOSB,
           ASTadr => 0,
           ASTPRM => 0,
           P1     => S,
           P2     => 1,
           P3     => 0,
           P4     => (0,0),
           P5     => 0,
           P6     => 0);
      Char := S(1);
   end Get;

   procedure Put(Char : in Character) is
   begin
      Put(Char & "");
   end Put;

   procedure Put(Str : in String) is
      S : String(Str'Range) := Str;
   begin
      QIOW(Stat   => Stat,
           EFN    => 0,
           Chan   => Chan,
           Func   => 16#70#,
           IOSB   => IOSB,
           ASTadr => 0,
           ASTPRM => 0,
           P1     => S,
           P2     => S'Length,
           P3     => 0,
           P4     => (0,0),
           P5     => 0,
           P6     => 0);
   end Put;
begin
   Starlet.Assign(Stat, "TT:", Chan);
end Custom_IO;
-----




^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: How do I make HOTKEYS in ADA?
  1996-10-08  0:00 ` Jon S Anthony
                     ` (2 preceding siblings ...)
  1996-10-14  0:00   ` Norman H. Cohen
@ 1996-10-16  0:00   ` Jon S Anthony
  3 siblings, 0 replies; 11+ messages in thread
From: Jon S Anthony @ 1996-10-16  0:00 UTC (permalink / raw)



In article <32626229.7C51@watson.ibm.com> "Norman H. Cohen" <ncohen@watson.ibm.com> writes:

> Jon S Anthony wrote:
> 
> > Well, yes, but I didn't read that as acceptable either.  What you are
> > suggesting is some sort of "loop based scenario".  But this could
> > cause odd and unacceptable timing skews: check for character.  Nothing
> > at this moment.  Drop to next part of loop.  Do this work (might take
> > a while).  Mean time user is hitting key wondering what the #@&% is
> > wrong.  Finally get back to check for character...
> 
> Let a separate task poll for key presses.

Um, that's using tasking, right?  Which was my point (needs tasking or
ATC, go back and check...).

/Jon
-- 
Jon Anthony
Organon Motives, Inc.
Belmont, MA 02178
617.484.3383
jsa@organon.com





^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~1996-10-16  0:00 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1996-10-05  0:00 How do I make HOTKEYS in ADA? Randy Kosarik
1996-10-07  0:00 ` Tucker Taft
1996-10-08  0:00 ` Jon S Anthony
1996-10-10  0:00   ` Keith Thompson
1996-10-10  0:00     ` Larry Kilgallen
1996-10-11  0:00       ` Randy Kosarik
1996-10-15  0:00         ` John Herro
1996-10-11  0:00       ` Robert Dewar
1996-10-11  0:00   ` Jon S Anthony
1996-10-14  0:00   ` Norman H. Cohen
1996-10-16  0:00   ` Jon S Anthony

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