EKEY part 1 of 3 
Author Message
 EKEY part 1 of 3

David Petty suggested that I should post a discussion of EKEY , along
the lines of the character set stuff that I posted a couple of weeks
ago.  Here is a set of implementor's notes for EKEY that I have
submitted to the ANS Forth committee for possible inclusion in the
"Implementor's Guide" section of the ANS Forth document.

I am posting this in 3 parts, since it would otherwise exceed 100 lines.


EKEY Implementor's Notes                        Part 1 of 3

                              EKEY

EKEY provides access to a system-dependent set of keyboard events,
including members of the standard character set, other members of
the implementation- defined character set, and keystrokes that do
not correspond to members of the character set.

                        EKEY under MS-DOS

For example, consider a hypothetical Forth system running under
MS-DOS on a PC-compatible computer.  Assume that the
implementation-defined character set is the "normal" 8-bit PC
character set.  In that character set, the codes from 0 to 127
correspond to ASCII characters.  The codes from 128 to 255 represent
characters from various non-English languages, mathematical symbols,
and some graphical symbols used for line drawing.  In addition to
those characters, the keyboard can generate various other "scan
codes", representing such non-character events as arrow keys and
function keys.

When a program asks the MS-DOS operating system for a keyboard
event, it receives either a single nonzero byte, representing a
character, or a zero byte followed by a "scan code" byte,
representing a non-character keyboard event (e.g.  a function key).

EKEY represents each keyboard event as a single number, rather than
as a sequence of numbers.  Characters are encoded as numbers
beginning at 0, and non-character events are encoded as numbers
larger than the largest valid character.  For the system described
above, the following would be a reasonable implementation of EKEY
and related words.

        The MAX-CHAR environmental query would return 255.

        Assume the existence of a word DOS-KEY ( -- char )  which
        executes the MS-DOS "Direct STDIN Input" system call
        (Interrupt 21h, Function 07h) and a word DOS-KEY? ( -- 0|ff)
        which executes the MS-DOS "Check STDIN Status" system call
        (Interrupt 21h, Function 0Bh).

        : EKEY?  ( -- flag )  DOS-KEY?  0<>  ;
        : EKEY  ( -- u )
           DOS-KEY  ?DUP  0=  IF
              DOS-KEY  DUP 3  =  IF  DROP 0  ELSE  256 +  THEN
           THEN
        ;



Fri, 07 Jan 1994 21:58:19 GMT  
 
 [ 1 post ] 

 Relevant Pages 

1. EKEY part 3 of 3

2. EKEY part 2 of 3

3. KEY , EKEY , AND EKEY>CHAR

4. IDLE-EKEY?

5. EKEY in gforth in DOS

6. EKEY in gforth for linux?

7. KEY and EKEY

8. EKEY>CHAR in Win32Forth

9. portable definitions for KEY and EKEY?

10. EKEY and double numbers

11. KEY and EKEY

12. Key and EKey

 

 
Powered by phpBB® Forum Software