×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Recognize INKEY()

Recognize INKEY()

Recognize INKEY()

(OP)
Hi,

There is another thing I couldn’t do: using/checking the Environment Function INKEY()

I did all I now to check this function, but it always return me a 0 (zero).
I’m trying to recognize the ENTER key when pressed. INKEY()returns a zero and it should be (as far as I know) a 13.

Sorry to ask this banalities, but I’m fixing a very old dbase program and my knowledge about this program language is very scarce, that’s why I asking you, people that know exactly how to cut the cheese wink

(Any other way of recognize when press the ENTER key would be appreciated)

Thanks smile
Antonio

P.S.
My program is dBase III Plus V 1.1 - The Function READKEY() returns ALWAYS 271 - What am I doing wrong?

RE: Recognize INKEY()

It's been a while since I worked with dBase. (One reason is that the version I had, dBase 5.0 for DOS only worked up to Windows XP operating systems. When I jumped from XP to Win 7, it stopped working.) Probably you need to find a DBASE language manual. Somewhat similar Visual FoxPro probably hasn't changed it much since it branched off.

In VFP the INKEY() function without a value as parameter returns the current key pressed. Using INKEY(0) forces it to wait for a keypress.

The codes can be found here:
http://www.dbforums.com/showthread.php?1007860-dBa...

CODE

Key Alone Shift Ctrl Alt
--- ----- ----- ---- ---
F1 28 84 94 104
F2 -1 85 95 105
F3 -2 86 96 106
F4 -3 87 97 107
F5 -4 88 98 108
F6 -5 89 99 109
F7 -6 90 100 110
F8 -7 91 101 111
F9 -8 92 102 112
F10 -9 93 103 113
F11 133 135 137 139
F12 134 136 138 140
1 49 33 - 120
2 50 64 33 121
3 51 35 - 122
4 52 36 - 123
5 53 37 - 124
6 54 94 30 125
7 55 38 - 126
8 56 42 - 127
9 57 40 - 128
0 48 41 - 19
a 97 65 1 30
b 98 66 2 48
c 99 67 3 46
d 100 68 4 32
e 101 69 5 18
f 102 70 6 33
g 103 71 7 34
h 104 72 127 35
i 105 73 9 23
j 106 74 10 36
k 107 75 11 37
l 108 76 12 38
m 109 77 13 50
n 110 78 14 49
o 111 79 15 24
p 112 80 16 25
q 113 81 17 16
r 114 82 18 19
s 115 83 19 31
t 116 84 20 20
u 117 85 21 22
v 118 86 22 47
w 119 87 23 17
x 120 88 24 45
y 121 89 25 21
z 122 90 26 44
INS 22 22 146 162
HOME 1 1 29 151
DEL 7 7 147 163
END 6 6 23 159
PGUP 18 18 31 153
PGDN 3 51 30 161
UP 5 5 141 152
RIGHT 4 4 2 157
LEFT 19 19 26 155
DOWN 24 24 145 160
ESCAPE 27 27 27 1
ENTER 13 13 10 28
BSPACE 127 127 127 14
TAB 9 15 148 165 

RE: Recognize INKEY()

(OP)
Thank you dbMark, but nothing to do...

Could you explain me how to check the pressed key from the beginning, from the dBase dot prompt?

I got two books: “Using dBase III Plus” writing by E. Jones - 1987 where INKEY() doesn’t exist (see attached index image), and “dBase III / III Plus - Instant Reference” by Alan Simpson - 1988, where INKEY() do appear, but I wasn’t able to check… evil



Thanks.

RE: Recognize INKEY()

Here's another link:
http://www.dbase.com/help/Application_Shell/IDH_AP...

Quote:

INKEY([<seconds expN>] [, <mouse expC>])

<seconds expN>

The number of seconds INKEY( ) waits for a keystroke. Fractional times are allowed. If <expN> is zero, INKEY( ) waits indefinitely for a keystroke. If <expN> is less than zero, the parameter is ignored.

<mouse expC>

Determines whether INKEY( ) returns a value when you click the mouse. If <expC> is "M" or "m", INKEY( ) returns –100. If <expC> is not "M" or "m", INKEY( ) ignores a mouse click and waits for a keystroke.

The above is probably current behavior. I can't verify how your earlier version from the 1980s handled it. Try this at the dot prompt:

CODE

? INKEY(0) 

RE: Recognize INKEY()

(OP)
Hi dbMark,

in response to your post, I had attached two images that talk by themselves.



Thank you anyway.

Antonio

RE: Recognize INKEY()

(OP)
Time ago, I did the following code to know the accented letters to use with CHR().
Notice that Inkey NEVER change. ('x' lower case to exit)

*AS.PRG
set talk off
wrow=1
wcol=1
ab=0
clear
do while ab<255
set color to r+
@ wrow,wcol say ab pict '999'
set color to
@ wrow,wcol+4 say chr(ab) pict 'aa'
ab=ab+1
wrow=wrow+1
if wrow=25
wrow=1
wcol=wcol+7
endif
if ab=255
set color to r
@ wrow,wcol say 'TheEnd'
wrow=wrow+2
endif
enddo
re=' '
set color to b
@ wrow,wcol-1 say 'READKEY()'
wrow=wrow+1
@ 24,wcol-1 say 'x to exit'
do while re<>'x'
set color to w
@wrow,wcol-1 say 'Key:' get re
read
if readkey()=15
set color to r
@ wrow+1,wcol say '15! '
@ wrow+2,wcol-1 say 'Inkey():'
@ wrow+3,wcol say INKEY()
else
set color to gr+
@ wrow+1,wcol say 'Not 15!'
@ wrow+2,wcol-1 say 'Inkey():'
@ wrow+3,wcol say INKEY()
endif
enddo

RE: Recognize INKEY()

Place a space after the '?' and try that.

? INKEY(0)

If that minor change does not work then it is possible your function's early version will not accept a parameter. How about this? Understand that it is an endless loop that will display the number of the key combinations pressed until the ESC key is pressed.

CODE

DO WHILE LASTKEY() <> 27  && Exit loop if ESC key was pressed
   nVal = INKEY()
   IF nVal <> 0
      ? nVal
   ENDIF
ENDDO 

RE: Recognize INKEY()

(OP)
With SPACE (it also works without):



Your code:





In my dBase, LASTKEY() doesn't exist:

RE: Recognize INKEY()

Try this:

CODE

DO WHILE .T.  && potentially endless loop
   nVal = INKEY()
   IF nVal <> 0
      ? nVal
      IF nVal = 27
         EXIT  && Exit loop if ESC key was pressed
      ENDIF
   ENDIF
ENDDO 

RE: Recognize INKEY()

(OP)
Nothing...

Loops with 0's.
Doesn't respond to any key pressed.





sad

RE: Recognize INKEY()

What you saw was the looping while waiting for input. I have added SET TALK ON|OFF lines to avoid that. SET TALK ON is helpful at the dot prompt but is usually set OFF within applications.

CODE

DO WHILE .T.  && potentially endless loop
   SET TALK OFF  && hides variable assignments
   nVal = INKEY()
   SET TALK ON
   IF nVal <> 0
      ? nVal
      IF nVal = 27  && Not needed if SET ESCAPE ON
         EXIT       && Exit loop if ESC key was pressed
      ENDIF
   ENDIF
ENDDO 

RE: Recognize INKEY()

(OP)
It worked!
Thanks dbMark thumbsup2

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close