1. keyread.e:

Hi,

Hawke referred me to "keyread.e" to be able to see when a key is released,
so I'm trying to see how to use it; the author says to use his
"clear_keys()" procedure if you use the regular "get_key()" in addition to
his "get_keys()", which I do, so I did, but it crashes *with* the "clear"
procedure and doesn't without.

Has anyone used this "get_keys()" function before who might know what's
going on?  I don't want to invite random crashes into my program if it needs
the "clear" like he says, but it seems to *make* crashes instead of fix
them.

(I did try putting the "clear" after the author's function "get_keys()"
instead of after "get_key()", but that crashed too, after press key 3
times.)

Dan Moyer

< demo program of problem after following>


<keyread.e author says:>
--
-- Everyone using my keyread.e include file should now replace it with this
-- updated version. A bug has been fixed that could cause it to crash
-- (in programs that use it along with the ordinary input routines).
-- It has a new procedure, clear_keys(), that should be called after any
-- calls to these normal routines, i.e. get_key(), gets(0), etc., but it
-- is not necessary if your program uses only get_keys().
--
-- Regards,
--             Michael Bolin
--             February 4, 1998

<code example begins>

-- ORIGINALLY:
-- find out what numeric key code is generated by any key on the keyboard
-- usage:
--          ex key

--NOW:
-- test usage of keyread.e

include keyread.e

integer code
sequence someKeys

puts(1, "Press any key. I'll show you the key code. Press q to quit\n\n")
while 1 do
    code = get_key()
--  clear_keys()  -- if left in, this crashes after a few keypresses, even
though
--   --it is "supposed" to be there to *prevent* crashes
    if code != -1 then
       printf(1, "The key code is: %d\n", code)
       if code = 'q' then
         exit
      end if
    end if

    someKeys = get_keys()
    if length(someKeys) != 0 then
        print(1, someKeys)
        if code = 'q' then
           exit
        end if
    end if

end while

new topic     » topic index » view message » categorize

2. Re: keyread.e:

Why leave in get_key? I'm not sure, but I think that might be your problem.
Since get_key and get_keys both handle keystrokes, perhaps using get_key is
messing up get_keys. You might replace get_key with get_keys.

Jeff Fielding

On Mon, 28 Aug 2000, you wrote:
> Hi,
>
> Hawke referred me to "keyread.e" to be able to see when a key is released,
> so I'm trying to see how to use it; the author says to use his
> "clear_keys()" procedure if you use the regular "get_key()" in addition to
> his "get_keys()", which I do, so I did, but it crashes *with* the "clear"
> procedure and doesn't without.
>
> Has anyone used this "get_keys()" function before who might know what's
> going on?  I don't want to invite random crashes into my program if it needs
> the "clear" like he says, but it seems to *make* crashes instead of fix
> them.
>
> (I did try putting the "clear" after the author's function "get_keys()"
> instead of after "get_key()", but that crashed too, after press key 3
> times.)
>
> Dan Moyer
>
> < demo program of problem after following>
>
>
> <keyread.e author says:>
> --
> -- Everyone using my keyread.e include file should now replace it with this
> -- updated version. A bug has been fixed that could cause it to crash
> -- (in programs that use it along with the ordinary input routines).
> -- It has a new procedure, clear_keys(), that should be called after any
> -- calls to these normal routines, i.e. get_key(), gets(0), etc., but it
> -- is not necessary if your program uses only get_keys().
> --
> -- Regards,
> --             Michael Bolin
> --             February 4, 1998
>
> <code example begins>
>
> -- ORIGINALLY:
> -- find out what numeric key code is generated by any key on the keyboard
> -- usage:
> --          ex key
>
> --NOW:
> -- test usage of keyread.e
>
> include keyread.e
>
> integer code
> sequence someKeys
>
> puts(1, "Press any key. I'll show you the key code. Press q to quit\n\n")
> while 1 do
>     code = get_key()
> --  clear_keys()  -- if left in, this crashes after a few keypresses, even
> though
> --   --it is "supposed" to be there to *prevent* crashes
>     if code != -1 then
>        printf(1, "The key code is: %d\n", code)
>        if code = 'q' then
>          exit
>       end if
>     end if
>
>     someKeys = get_keys()
>     if length(someKeys) != 0 then
>         print(1, someKeys)
>         if code = 'q' then
>            exit
>         end if
>     end if
>
> end while

new topic     » goto parent     » topic index » view message » categorize

3. Re: keyread.e:

Jeff,

Makes sense, and I may have to, but the example I sent was just that, a
simple example; in the program I'm actually trying to use it in (a
"keybanger" for kids), I'm only using get_keys() in *one* place, once,  (and
it *mostly* works there, & nothing else did as well as it does, though it
does eventually just stop working, no crash, just doesn't seem to return
keypresses after a while of pressing keys which are sensed by get_key()),
and I'm using get_key() in a whole *bunch* of submodules, a *lot*, and
specifically using the integer return from it, and I think that when I first
started this program (a good while ago & then stopped working on it), I did
all sorts of stuff to "optimize" it with regards to "get_key()" (at least
partly to try to avoid key buffer overflow on a slower machine that would
"beep" if you held the key down too long), & I'd probably have to go back &
tear it all out to not interfere with get_keys(), & I'd rather not if I
could have them work together.

But I agree, using them together is probably the problem,  sigh.  I was
hoping maybe someone *had* used them together, ran into a problem, and
*fixed* it, :)

Dan Moyer


----- Original Message -----
From: "Jeffrey Fielding" <JJProg at CYBERBURY.NET>
To: <EUPHORIA at LISTSERV.MUOHIO.EDU>
Sent: Monday, August 28, 2000 5:32 AM
Subject: Re: keyread.e:


> Why leave in get_key? I'm not sure, but I think that might be your
problem.
> Since get_key and get_keys both handle keystrokes, perhaps using get_key
is
> messing up get_keys. You might replace get_key with get_keys.
>
> Jeff Fielding
>
> On Mon, 28 Aug 2000, you wrote:
> > Hi,
> >
> > Hawke referred me to "keyread.e" to be able to see when a key is
released,
> > so I'm trying to see how to use it; the author says to use his
> > "clear_keys()" procedure if you use the regular "get_key()" in addition
to
> > his "get_keys()", which I do, so I did, but it crashes *with* the
"clear"
> > procedure and doesn't without.
> >
> > Has anyone used this "get_keys()" function before who might know what's
> > going on?  I don't want to invite random crashes into my program if it
needs
> > the "clear" like he says, but it seems to *make* crashes instead of fix
> > them.
> >
> > (I did try putting the "clear" after the author's function "get_keys()"
> > instead of after "get_key()", but that crashed too, after press key 3
> > times.)
> >
> > Dan Moyer
> >
> > < demo program of problem after following>
> >
> >
> > <keyread.e author says:>
> > --
> > -- Everyone using my keyread.e include file should now replace it with
this
> > -- updated version. A bug has been fixed that could cause it to crash
> > -- (in programs that use it along with the ordinary input routines).
> > -- It has a new procedure, clear_keys(), that should be called after any
> > -- calls to these normal routines, i.e. get_key(), gets(0), etc., but it
> > -- is not necessary if your program uses only get_keys().
> > --
> > -- Regards,
> > --             Michael Bolin
> > --             February 4, 1998
> >
> > <code example begins>
> >
> > -- ORIGINALLY:
> > -- find out what numeric key code is generated by any key on the
keyboard
> > -- usage:
> > --          ex key
> >
> > --NOW:
> > -- test usage of keyread.e
> >
> > include keyread.e
> >
> > integer code
> > sequence someKeys
> >
> > puts(1, "Press any key. I'll show you the key code. Press q to
quit\n\n")
> > while 1 do
> >     code = get_key()
> > --  clear_keys()  -- if left in, this crashes after a few keypresses,
even
> > though
> > --   --it is "supposed" to be there to *prevent* crashes
> >     if code != -1 then
> >        printf(1, "The key code is: %d\n", code)
> >        if code = 'q' then
> >          exit
> >       end if
> >     end if
> >
> >     someKeys = get_keys()
> >     if length(someKeys) != 0 then
> >         print(1, someKeys)
> >         if code = 'q' then
> >            exit
> >         end if
> >     end if
> >
> > end while

new topic     » goto parent     » topic index » view message » categorize

4. Re: keyread.e:

You could override get_key() to use get_keys(), but modify the return value
to be in the format of get_key().

Jeff

On Mon, 28 Aug 2000, you wrote:
> Jeff,
>
> Makes sense, and I may have to, but the example I sent was just that, a
> simple example; in the program I'm actually trying to use it in (a
> "keybanger" for kids), I'm only using get_keys() in *one* place, once,  (and
> it *mostly* works there, & nothing else did as well as it does, though it
> does eventually just stop working, no crash, just doesn't seem to return
> keypresses after a while of pressing keys which are sensed by get_key()),
> and I'm using get_key() in a whole *bunch* of submodules, a *lot*, and
> specifically using the integer return from it, and I think that when I first
> started this program (a good while ago & then stopped working on it), I did
> all sorts of stuff to "optimize" it with regards to "get_key()" (at least
> partly to try to avoid key buffer overflow on a slower machine that would
> "beep" if you held the key down too long), & I'd probably have to go back &
> tear it all out to not interfere with get_keys(), & I'd rather not if I
> could have them work together.
>
> But I agree, using them together is probably the problem,  sigh.  I was
> hoping maybe someone *had* used them together, ran into a problem, and
> *fixed* it, :)
>
> Dan Moyer

new topic     » goto parent     » topic index » view message » categorize

5. Re: keyread.e:

Why don't you use only the get_keys function even for a single key
and not mix them?

new topic     » goto parent     » topic index » view message » categorize

Search



Quick Links

User menu

Not signed in.

Misc Menu