comp.lang.ada
 help / color / mirror / Atom feed
* key strokes intercept
@ 1999-03-30  0:00 fluffy_puff
  1999-03-30  0:00 ` Matthew Heaney
                   ` (2 more replies)
  0 siblings, 3 replies; 15+ messages in thread
From: fluffy_puff @ 1999-03-30  0:00 UTC (permalink / raw)


Hi,

I'm taking a programming course, using Ada 95, and I've played with VB
and C++ before.  In Visual Basic I could use some pre-defined
subprograms to control key strokes in real time (as they happened, as
opposed to after the <Return> key has been pressed): KeyDown, KeyUp,
KeyCode, stuff like that.

How do I do this in Ada ?  I just need sort of a starting point where
I can look for the info.  I have a beginner level book that's pretty
good but doesn't touch this topic at all.  I couldn't find anything
either in the online help I have.

What is "GNAT" ?

All I can say about the compiler I use is what the "About" box shows:
ObjectAda for Windows V7.1.105 (special edition)
Copyright (c) 1997, Aonix.

Thanks

Marc Galipeau
--
What I really am is "fluffy", no "_dong",
no "_puff", no "_woo", no  nothing, just plain fluffy.






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

* Re: key strokes intercept
  1999-03-30  0:00 key strokes intercept fluffy_puff
@ 1999-03-30  0:00 ` Matthew Heaney
  1999-03-30  0:00   ` Marin David Condic
                     ` (2 more replies)
  1999-03-30  0:00 ` David C. Hoos, Sr.
  1999-03-31  0:00 ` Stephen Leake
  2 siblings, 3 replies; 15+ messages in thread
From: Matthew Heaney @ 1999-03-30  0:00 UTC (permalink / raw)


fluffy_puff@dsuper.net writes:

> I'm taking a programming course, using Ada 95, and I've played with VB
> and C++ before.  In Visual Basic I could use some pre-defined
> subprograms to control key strokes in real time (as they happened, as
> opposed to after the <Return> key has been pressed): KeyDown, KeyUp,
> KeyCode, stuff like that.
> 
> How do I do this in Ada ?  

By using Ada.Text_IO.Get_Immediate.


> I just need sort of a starting point where I can look for the info.  I
> have a beginner level book that's pretty good but doesn't touch this
> topic at all.  I couldn't find anything either in the online help I
> have.

See RM95 A.10.7 (11).

You're new to Ada, so what this means is

RM95     - the Ada95 Reference Manual
A        - Annex A, the predefined packages
A.10     - section A.10, which describes Text_IO
A.10.7   - subsection A.10.7, I/O for strings and chars
(11)     - paragraph 11, the description of Get_Immediate, and 
           also the loudest volume on Nigel Tufnel's amplifier
           
There's a reference manual on-line at the ada home page.

<http://www.adahome.com/>

 
> What is "GNAT" ?

The name of a zero-cost, high-quality Ada95 compiler.  GNAT is a member
of the gcc compiler family.

<http://www.gnat.com/>

Follow the Students link from their web page for more info.


> All I can say about the compiler I use is what the "About" box shows:
> ObjectAda for Windows V7.1.105 (special edition)
> Copyright (c) 1997, Aonix.


The student edition from Aonix is another free Ada95 compiler.


You may find it helpful to read Ada95 source code written by an, um,
expert in the language.  I have converted every C++ example in the GoF
design patterns book to Ada95, and have now started documenting
concurrency idioms.

<http://www.acm.org/archives/patterns.html>
<mailto:patterns@acm.org>


You can subscribe to the ACM patterns list by sending the message (body)

subscribe patterns <your full name>


to the ACM mailing-list server.

<mailto:listserv@acm.org>








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

* Re: key strokes intercept
  1999-03-30  0:00 key strokes intercept fluffy_puff
  1999-03-30  0:00 ` Matthew Heaney
@ 1999-03-30  0:00 ` David C. Hoos, Sr.
  1999-03-31  0:00   ` fluffy_bud
  1999-03-31  0:00 ` Stephen Leake
  2 siblings, 1 reply; 15+ messages in thread
From: David C. Hoos, Sr. @ 1999-03-30  0:00 UTC (permalink / raw)



fluffy_puff@dsuper.net wrote in message
<370160f9.569041534@news.dsuper.net>...
>Hi,
>
>I'm taking a programming course, using Ada 95, and I've played with VB
>and C++ before.  In Visual Basic I could use some pre-defined
>subprograms to control key strokes in real time (as they happened, as
>opposed to after the <Return> key has been pressed): KeyDown, KeyUp,
>KeyCode, stuff like that.
>
>How do I do this in Ada ?  I just need sort of a starting point where
>I can look for the info.  I have a beginner level book that's pretty
>good but doesn't touch this topic at all.  I couldn't find anything
>either in the online help I have.
>
There is a set of four Get_Immediate procedures defined in RM95 A.10.1
which get the next keystroke from either the Standard Input (usually
the keyboard) or from an open text file, and either return when the
next character is available, or set a Boolean variable indicating
whether there was a new character available.  The combinations of
these options make up the four overloaded procedures.

If you do not have the Ada95 Reference Manual (RM95), its available
in Windows Help format on my FTP site in the directory
ftp://ada95.com/pub/rm95-winhelp/

>What is "GNAT" ?

GNAT is a freely-availabel compiler of the GNU family, with
implementations on a wide variety of platforms -- various flavors of
UNIX, Windows9X/NT, DOS, Macintosh, etc.

The public versions produced by Ada Core Techoligies (ACT) are
available at ftp://ftp.cs.nyu/edy/pub/gnat, while others done by
volunteers are available at various places.

>All I can say about the compiler I use is what the "About" box shows:
>ObjectAda for Windows V7.1.105 (special edition)
>Copyright (c) 1997, Aonix.
>
This is an edition included with various textbooks, but is limited
in the size and complexity of the programs which it can produce.
There is a commercial version available without the limitations.







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

* Re: key strokes intercept
  1999-03-30  0:00 ` Matthew Heaney
  1999-03-30  0:00   ` Marin David Condic
@ 1999-03-30  0:00   ` Magnus Larsson
  1999-03-30  0:00     ` Tom Moran
  1999-03-31  0:00   ` fluffy_bud
  2 siblings, 1 reply; 15+ messages in thread
From: Magnus Larsson @ 1999-03-30  0:00 UTC (permalink / raw)


In article <m3n20vfhsv.fsf@mheaney.ni.net>,
  Matthew Heaney <matthew_heaney@acm.org> wrote:
> fluffy_puff@dsuper.net writes:
>
> > I'm taking a programming course, using Ada 95, and I've played with VB
> > and C++ before.  In Visual Basic I could use some pre-defined
> > subprograms to control key strokes in real time (as they happened, as
> > opposed to after the <Return> key has been pressed): KeyDown, KeyUp,
> > KeyCode, stuff like that.
> >
> > How do I do this in Ada ?
>
> By using Ada.Text_IO.Get_Immediate.

As he talks about VB in the previous sentence, I'm most certain that he means
something like the GuiBuilder (distributed with the professional(?) edition of
Objectada).

/Magnus

     .|,
     -o----
mla@omicron.se

-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/       Search, Read, Discuss, or Start Your Own    




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

* Re: key strokes intercept
  1999-03-30  0:00 ` Matthew Heaney
@ 1999-03-30  0:00   ` Marin David Condic
  1999-04-01  0:00     ` Aidan Skinner
  1999-03-30  0:00   ` Magnus Larsson
  1999-03-31  0:00   ` fluffy_bud
  2 siblings, 1 reply; 15+ messages in thread
From: Marin David Condic @ 1999-03-30  0:00 UTC (permalink / raw)


Matthew Heaney wrote:
> 
> (11)     - paragraph 11, the description of Get_Immediate, and
>            also the loudest volume on Nigel Tufnel's amplifier

I believe it was the *guitar* that went to eleven - not the amplifier.

MDC
-- 
Marin David Condic
Real Time & Embedded Systems, Propulsion Systems Analysis
United Technologies, Pratt & Whitney, Large Military Engines
M/S 731-95, P.O.B. 109600, West Palm Beach, FL, 33410-9600
***To reply, remove "bogon" from the domain name.***




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

* Re: key strokes intercept
  1999-03-30  0:00   ` Magnus Larsson
@ 1999-03-30  0:00     ` Tom Moran
  0 siblings, 0 replies; 15+ messages in thread
From: Tom Moran @ 1999-03-30  0:00 UTC (permalink / raw)


>As he talks about VB in the previous sentence, I'm most certain that he means
>something like the GuiBuilder (distributed with the professional(?) edition of
>Objectada).
Get_Immediate is certainly the simplest approach, but he may want a
"When_Keydown" Windows-style thing instead.  In that case he needs
either one of the thin Windows bindings available with ObjectAda or
Gnat (which may be more than a little heavy going for a new Ada user),
or a thick binding which already incorporates routines like
When_Keydown etc.  In the latter case, I modestly suggest looking at
CLAW, a free version of which (around 250K) is available for download
from www.rrsoftware.com  It comes in source form with slight variants
(OS-interaction routines and limitation work-arounds) as needed for
different PC Ada 95 compilers.    




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

* Re: key strokes intercept
  1999-03-30  0:00 ` David C. Hoos, Sr.
@ 1999-03-31  0:00   ` fluffy_bud
  1999-04-01  0:00     ` Aidan Skinner
  0 siblings, 1 reply; 15+ messages in thread
From: fluffy_bud @ 1999-03-31  0:00 UTC (permalink / raw)


On Tue, 30 Mar 1999 03:49:40 -0600, "David C. Hoos, Sr."
<david.c.hoos.sr@ada95.com> wrote:

>There is a set of four Get_Immediate procedures ...

>GNAT is a freely-availabel compiler of the GNU family,

OK, now what is GNU ?

> ... with
>implementations on a wide variety of platforms -- various flavors of
>UNIX, Windows9X/NT, DOS, Macintosh, etc.
>
>The public versions produced by Ada Core Techoligies (ACT) are
>available at ftp://ftp.cs.nyu/edy/pub/gnat, while others done by
>volunteers are available at various places.
>
>>All I can say about the compiler I use is what the "About" box shows:
>>ObjectAda for Windows V7.1.105 (special edition)
>>Copyright (c) 1997, Aonix.
>>
>This is an edition included with various textbooks, but is limited
>in the size and complexity of the programs which it can produce.
>There is a commercial version available without the limitations.

Thank you.  I guess I'll go check out the ACT, or the edy-at-nyu site.


Marc Galipeau
--
What I really am is "fluffy", no "_dong",
no "_puff", no "_woo", no  nothing, just plain fluffy.






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

* Re: key strokes intercept
  1999-03-30  0:00 ` Matthew Heaney
  1999-03-30  0:00   ` Marin David Condic
  1999-03-30  0:00   ` Magnus Larsson
@ 1999-03-31  0:00   ` fluffy_bud
  2 siblings, 0 replies; 15+ messages in thread
From: fluffy_bud @ 1999-03-31  0:00 UTC (permalink / raw)


Sorry about the e-mail.  I meant to post here but pushed the wrong
button in a moment of distraction.  Then I did the same thing to the
person who replied to your post.  I've got to find a trick to help me
not do that so much.

Marc
--
What I really am is "fluffy", no "_dong",
no "_puff", no "_woo", no  nothing, just plain fluffy.






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

* Re: key strokes intercept
  1999-03-30  0:00 key strokes intercept fluffy_puff
  1999-03-30  0:00 ` Matthew Heaney
  1999-03-30  0:00 ` David C. Hoos, Sr.
@ 1999-03-31  0:00 ` Stephen Leake
  1999-04-01  0:00   ` fluffy_doo
  2 siblings, 1 reply; 15+ messages in thread
From: Stephen Leake @ 1999-03-31  0:00 UTC (permalink / raw)


fluffy_puff@dsuper.net writes:

> Hi,
> 
> I'm taking a programming course, using Ada 95, and I've played with VB
> and C++ before.  In Visual Basic I could use some pre-defined
> subprograms to control key strokes in real time (as they happened, as
> opposed to after the <Return> key has been pressed): KeyDown, KeyUp,
> KeyCode, stuff like that.

KeyDown, KeyUp, KeyCode etc are Windows events. Visual Basic provides
a nice framework for handling events nicely. Plain Ada does not; you
need a thick binding to Windows to get that. I'm writing one called
Windex; after you learn some more about Ada, you could try it. See my
web page:

http://www.erols.com/leakstan/Stephe/index.html

The version there now does not provide access to the Key events, but I
just added that over the weekend, so check back soon (I'll announce
here when I release a new version). In the meantime, it will give you
a taste of what you are in for; don't be too scared, it gets easier
after you learn more. Look at the example Mandelplot application, not
the Windex code itself. It has handlers for mouse events; key events
will work similarly.

> 
> How do I do this in Ada ?  I just need sort of a starting point where
> I can look for the info.  I have a beginner level book that's pretty
> good but doesn't touch this topic at all.  I couldn't find anything
> either in the online help I have.

You need to get a good intro to Windows. I recommend Charles Petzold's
book (I think the title is "Programming Windows 95"). This will
explain about Windows events etc.
 
> What is "GNAT" ?

A free Ada compiler; you can download it from
ftp://cs.nyu.edu/pub/gnat/. For the Windows version, see the winnt/
directory; works nicely for Windows NT and Windows 95; should work
with Windows 98.

> All I can say about the compiler I use is what the "About" box shows:
> ObjectAda for Windows V7.1.105 (special edition)
> Copyright (c) 1997, Aonix.

This is another free Ada compiler, but it has several limitations (it
is old, has some known bugs, and will only compile relatively small
programs). I recommend downloading Gnat; it has a nice install script,
and is in some ways better than even the current version of ObjectAda.
On the other hand, Aonix does make a GUI builder that is trying to be
like Visual Basic (it has a _long_ way to go), so if you're interested
in helping them along, go buy the version of ObjectAda that provides
the GUIBuilder. Check their website at: www.aonix.com (hmm, doesn't
seem to be up right now).

> Thanks

You're welcome; hope this helps.

-- Stephe




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

* Re: key strokes intercept
  1999-03-31  0:00 ` Stephen Leake
@ 1999-04-01  0:00   ` fluffy_doo
  1999-04-01  0:00     ` Tom Moran
  1999-04-02  0:00     ` Jerry van Dijk
  0 siblings, 2 replies; 15+ messages in thread
From: fluffy_doo @ 1999-04-01  0:00 UTC (permalink / raw)


On 31 Mar 1999 14:50:37 -0500, Stephen Leake
<Stephen.Leake@gsfc.nasa.gov> wrote:

>KeyDown, KeyUp, KeyCode etc are Windows events. Visual Basic provides
>a nice framework for handling events nicely. Plain Ada does not; you
>need a thick binding to Windows to get that. I'm writing one called
>Windex; after you learn some more about Ada, you could try it. See my
>web page:
>
>http://www.erols.com/leakstan/Stephe/index.html

So right now there's no way to do what I want if I'm writing a DOS
program ?  I have maybe two weeks to get it into my program if I
decide that I want to try.  I'd use it as part of a password input
procedure, you know the asterix replacing whatever is typed in at the
keyboard.  Someone in this thread mentioned the text_IO.get_immediate
function, and I thought maybe I could try to use it and replace the
key code (or whatever I`ll have to play with) with the backspace
followed by the asterix, if I can't actually turn off the screen ECHO.

>The version there now does not provide access to the Key events, but I
>just added that over the weekend, so check back soon (I'll announce
>here when I release a new version). In the meantime, it will give you
>a taste of what you are in for; don't be too scared, it gets easier
>after you learn more. Look at the example Mandelplot application, not
>the Windex code itself. It has handlers for mouse events; key events
>will work similarly.

Thanks for this and all the rest.  I'll go visit your site.

Marc
--
What I really am is "fluffy", no "_dong",
no "_puff", no "_woo", no  nothing, just plain fluffy.






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

* Re: key strokes intercept
  1999-03-30  0:00   ` Marin David Condic
@ 1999-04-01  0:00     ` Aidan Skinner
  1999-04-05  0:00       ` Marin David Condic
  0 siblings, 1 reply; 15+ messages in thread
From: Aidan Skinner @ 1999-04-01  0:00 UTC (permalink / raw)


On Tue, 30 Mar 1999 12:34:05 -0500, Marin David Condic
<condicma@bogon.pwfl.com> wrote:

>Matthew Heaney wrote:
>> 
>> (11)     - paragraph 11, the description of Get_Immediate, and
>>            also the loudest volume on Nigel Tufnel's amplifier
>
>I believe it was the *guitar* that went to eleven - not the amplifier.

No, it's the amplifier. We have the classic scene on our wall.

- Aidan (who's amplifier goes up to 12)
-- 
"Every time I see her I want to geek..."
"I say geek. If she runs then it was never meant to be. But if you talk
about routers, TCP/IP and programming and she stays, she's yours until the
counter flips" 





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

* Re: key strokes intercept
  1999-03-31  0:00   ` fluffy_bud
@ 1999-04-01  0:00     ` Aidan Skinner
  0 siblings, 0 replies; 15+ messages in thread
From: Aidan Skinner @ 1999-04-01  0:00 UTC (permalink / raw)


On Wed, 31 Mar 1999 13:52:33 GMT, fluffy_bud@dsuper.net
<fluffy_bud@dsuper.net> wrote: 

>On Tue, 30 Mar 1999 03:49:40 -0600, "David C. Hoos, Sr."
><david.c.hoos.sr@ada95.com> wrote:

>>GNAT is a freely-availabel compiler of the GNU family,
>
>OK, now what is GNU ?

GNU's Not Unix. A project by the Free Software Foundation to create a
free (libre, not gratis) UNIX-like evironment. Part of this is the GNU
C compiler, gcc. GNAT uses the same code-generator as gcc, as do a
number of compilers for other languages (eg Fortran). 

- Aidan
-- 
"Every time I see her I want to geek..."
"I say geek. If she runs then it was never meant to be. But if you talk
about routers, TCP/IP and programming and she stays, she's yours until the
counter flips" 





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

* Re: key strokes intercept
  1999-04-01  0:00   ` fluffy_doo
@ 1999-04-01  0:00     ` Tom Moran
  1999-04-02  0:00     ` Jerry van Dijk
  1 sibling, 0 replies; 15+ messages in thread
From: Tom Moran @ 1999-04-01  0:00 UTC (permalink / raw)


>>KeyDown, KeyUp, KeyCode etc are Windows events. Visual Basic provides
>>a nice framework for handling events nicely. Plain Ada does not; you
>>need a thick binding to Windows
>So right now there's no way to do what I want if I'm writing a DOS
>program ?  I have maybe two weeks to get it into my program if I
>decide that I want to try.  I'd use it as part of a password input
>procedure, you know the asterix replacing whatever is typed in at the
>keyboard.
>... replace the
>key code (or whatever I`ll have to play with) with the backspace
>followed by the asterix, if I can't actually turn off the screen ECHO
No - there was just confusion about what you want.  The KeyDown etc VB
events are quite unnecessary for your password entry.  Use the
Get_Immediate as you plan, or, in DOS, use the DOS call to get a
character with no echo (see your compiler's vendor supplied library to
see how to make int21 or BIOS calls with your compiler).  
  The event approach is normally used in Windows and is most easily
done there using one of the thick Ada bindings.  You can also do it
using a separate task in DOS, but that's major overkill for password
entry.
  




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

* Re: key strokes intercept
  1999-04-01  0:00   ` fluffy_doo
  1999-04-01  0:00     ` Tom Moran
@ 1999-04-02  0:00     ` Jerry van Dijk
  1 sibling, 0 replies; 15+ messages in thread
From: Jerry van Dijk @ 1999-04-02  0:00 UTC (permalink / raw)


fluffy_doo@dsuper.net wrote:

: So right now there's no way to do what I want if I'm writing a DOS
: program ?  I have maybe two weeks to get it into my program if I
: decide that I want to try.  I'd use it as part of a password input
: procedure, you know the asterix replacing whatever is typed in at the
: keyboard.  Someone in this thread mentioned the text_IO.get_immediate
: function, and I thought maybe I could try to use it and replace the
: key code (or whatever I`ll have to play with) with the backspace
: followed by the asterix, if I can't actually turn off the screen ECHO.

If you are using the DOS compiler, why not use the conio binding that
comes with EZ2LOAD or on my homepage ?

One of the functions is:

	Getch
	-----
	Returns the character pressed. Unbuffered, no echo to the screen.

It has a lot of other useful functions too.

--
-- Jerry van Dijk | Leiden, Holland
-- Team Ada       | jdijk@acm.org
-- see http://stad.dsl.nl/~jvandyk




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

* Re: key strokes intercept
  1999-04-01  0:00     ` Aidan Skinner
@ 1999-04-05  0:00       ` Marin David Condic
  0 siblings, 0 replies; 15+ messages in thread
From: Marin David Condic @ 1999-04-05  0:00 UTC (permalink / raw)


Aidan Skinner wrote:
> 
> On Tue, 30 Mar 1999 12:34:05 -0500, Marin David Condic
> <condicma@bogon.pwfl.com> wrote:
> 
> >Matthew Heaney wrote:
> >>
> >> (11)     - paragraph 11, the description of Get_Immediate, and
> >>            also the loudest volume on Nigel Tufnel's amplifier
> >
> >I believe it was the *guitar* that went to eleven - not the amplifier.
> 
> No, it's the amplifier. We have the classic scene on our wall.
> 

I am big enough to admit when I'm wrong. Yes, upon reflection it *was*
the amplifier. I perhaps got it confused with the guitar that had
infinite sustain.

MDC

-- 
Marin David Condic
Real Time & Embedded Systems, Propulsion Systems Analysis
United Technologies, Pratt & Whitney, Large Military Engines
M/S 731-95, P.O.B. 109600, West Palm Beach, FL, 33410-9600
***To reply, remove "bogon" from the domain name.***




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

end of thread, other threads:[~1999-04-05  0:00 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1999-03-30  0:00 key strokes intercept fluffy_puff
1999-03-30  0:00 ` Matthew Heaney
1999-03-30  0:00   ` Marin David Condic
1999-04-01  0:00     ` Aidan Skinner
1999-04-05  0:00       ` Marin David Condic
1999-03-30  0:00   ` Magnus Larsson
1999-03-30  0:00     ` Tom Moran
1999-03-31  0:00   ` fluffy_bud
1999-03-30  0:00 ` David C. Hoos, Sr.
1999-03-31  0:00   ` fluffy_bud
1999-04-01  0:00     ` Aidan Skinner
1999-03-31  0:00 ` Stephen Leake
1999-04-01  0:00   ` fluffy_doo
1999-04-01  0:00     ` Tom Moran
1999-04-02  0:00     ` Jerry van Dijk

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