For Programmers: Free Programming Magazines  


Home > Archive > Clipper > June 2004 > The keyboard buffer during TBROWSE









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author The keyboard buffer during TBROWSE
A.M.

2004-06-16, 8:55 am

Hi at all.
Working with a TBROSEDB during the inkey() state, if I press a key, the
inkey function return the value of the key pressed.
BUT if I write a string and not one key only and if I want to display this
string that is certainly into the buffrer of the jeybord, how can I do?
Thank
P.Pietro


Stephen Quinn

2004-06-16, 8:55 am

P.Pietro

> BUT if I write a string and not one key only and if I want to display this
> string that is certainly into the buffrer of the jeybord, how can I do?


KEYBOARD 'This is a string' + CHR(13)

You might have problems with the TBrowse understanding that piece of text though<g>

--
HTH
Steve Quinn


A.M.

2004-06-16, 3:55 pm

And how can I do to read the keyboard buffer that I filled with the command
keyboard "This is a string"+chr(15)?
In other words:
How can I do to have back the string you wrote?
P.Pietro
"Stephen Quinn" <steveqNOSPAM@integritynet.com.au> ha scritto nel messaggio
news:2jaghkFvdeutU1@uni-berlin.de...
> P.Pietro
>
this[color=darkred]
>
> KEYBOARD 'This is a string' + CHR(13)
>
> You might have problems with the TBrowse understanding that piece of text

though<g>
>
> --
> HTH
> Steve Quinn
>
>



AUGE_OHR

2004-06-16, 3:55 pm

hi,

**** sample ****
FUNCTION TB_KEY()
LOCAL nKey, cString := ""

DO WHILE lmore
nKey := INKEY(0.1)
DO CASE
CASE nKey = K_UP
CASE nKey = K_DOWN
...
CASE nKey = K_SHOW_my_STRING
CASE nKey = K_DEL
OTHERWISE
cString := cString +CHR(nkey)
ENDCASE
ENDDO
RETURN nKey

greetings by OHR
Jimmy


gabor salai

2004-06-16, 3:55 pm

"AUGE_OHR" <AUGE_OHR@CSI.COM> wrote in message
news:caq1o6$l29$02$1@news.t-online.com...
> hi,
>
> **** sample ****
> FUNCTION TB_KEY()
> LOCAL nKey, cString := ""
>
> DO WHILE lmore
> nKey := INKEY(0.1)
> DO CASE
> CASE nKey = K_UP
> CASE nKey = K_DOWN
> ...
> CASE nKey = K_SHOW_my_STRING
> CASE nKey = K_DEL
> OTHERWISE
> cString := cString +CHR(nkey)
> ENDCASE
> ENDDO
> RETURN nKey


i think the idea of op was:
how to *read/examine* contents of keyboard buffer?

is there any lib having some key_buffer() function,
returning buffer contents [at moment of executing] as string?
later program may examine that string and discover what keys exactly,
and in what order, were waiting to be fetched from buffer.




AUGE_OHR

2004-06-16, 8:55 pm


> i think the idea of op was:
> how to *read/examine* contents of keyboard buffer?


PROCEDURE MAIN
LOCAL cString := "This is a Test"
LOCAL nKey := 0
KEYBOARD cString
DO WHILE .T.
nKey := INKEY(0)
? CHR(NEXTKEY())
IF nKey = 27
EXIT
ENDIF
ENDDO
RETURN

greetings by OHR
Jimmy


Stephen Quinn

2004-06-16, 8:55 pm

P.Pietro

> And how can I do to read the keyboard buffer that I filled with the command
> keyboard "This is a string"+chr(15)?
> In other words:


That was a CHR(13) (Carriage return) not CHR(15) I wrote

> How can I do to have back the string you wrote?

If you want to do it within the TBrowse loop then you need to do it 1 character at a time to build
up the string

If not in a loop the just stuff it in using the command shown previously.

You'll have to give more details on what your trying to achieve to get a more meaningful answer.

> BUT if I write a string and not one key only and if I want to display
> this string that is certainly into the buffrer of the jeybord, how can I do?

If you want to display it then why do you need to put it in the keyboard buffer at all??

--
HTH
Steve Quinn


gabor salai

2004-06-17, 3:55 am

"AUGE_OHR" <AUGE_OHR@CSI.COM> wrote in message
news:caqbri$uae$00$1@news.t-online.com...
>
>
> PROCEDURE MAIN
> LOCAL cString := "This is a Test"
> LOCAL nKey := 0
> KEYBOARD cString
> DO WHILE .T.
> nKey := INKEY(0)
> ? CHR(NEXTKEY())
> IF nKey = 27
> EXIT
> ENDIF
> ENDDO
> RETURN


sorry, i missed to explain me clearly.
i meant "examine" *nondestructively*
with "inkey()" you are efectively *removing* chars from
buffer, thus you change it.
of course, after removing all the chars from buffer, you
may put them back, but that is not "elegant" solution.
and also, there is danger to miss some key arrived in
the very moment while you are "examining" buffer on this way.





AUGE_OHR

2004-06-17, 3:55 pm

hi

> sorry, i missed to explain me clearly.
> i meant "examine" *nondestructively*
> with "inkey()" you are efectively *removing* chars from
> buffer, thus you change it.
> of course, after removing all the chars from buffer, you
> may put them back, but that is not "elegant" solution.
> and also, there is danger to miss some key arrived in
> the very moment while you are "examining" buffer on this way.


Yes your are right, but P.Pietro ask how to get back what he store into
KEYBOARD

>And how can I do to read the keyboard buffer that I filled with the
>command keyboard "This is a string"+chr(15)?


This he can do with NEXTKEY()

greetings by OHR
Jimmy


gabor salai

2004-06-17, 3:55 pm

"AUGE_OHR" <AUGE_OHR@CSI.COM> wrote in message
news:cas6n5$i4p$03$1@news.t-online.com...
> hi
>
>
> Yes your are right, but P.Pietro ask how to get back what he store into
> KEYBOARD
>
>
> This he can do with NEXTKEY()
>


yes, you are right.
but "nextkex()" is operating only on *one* next char, not
telling anything about other chars, waiting in *fifo* buffer.

also, i am afraid that pietro had simplified his question, to be
more clear, but he in fact wants to examine
buffer without destroying it.



AUGE_OHR

2004-06-17, 3:55 pm

hi

> but "nextkex()" is operating only on *one* next char, not
> telling anything about other chars, waiting in *fifo* buffer.


did you run the Sample ?
NextKey() return "all" char which was stuff into KEYBOARD.
(this is why i use CHR(NextKey()) to verify my cString)

>also, i am afraid that pietro had simplified his question, to be more clear


yes, so it is up to peitro to show some snip of code what he wanted to do

greetings by OHR
Jimmy


gabor salai

2004-06-17, 3:55 pm

"AUGE_OHR" <AUGE_OHR@CSI.COM> wrote in message
news:caskln$rmn$01$1@news.t-online.com...
> hi
>
>
> did you run the Sample ?
> NextKey() return "all" char which was stuff into KEYBOARD.
> (this is why i use CHR(NextKey()) to verify my cString)
>
clear[color=darkred]
>
> yes, so it is up to peitro to show some snip of code what he wanted to do
>


yes, "nextkey()" returnall of chars from buffer, but in a loop,
in combination with "inkey()", which is effectively
*destroying* the contents of buffer!

i *hoped* to find functtion [hypothetical]
cbuffer := keyboard_buffer()

and, later, i could do:
for i := 1 to len(cbuffer)
?substr(cbuffer, i, 1)
next i

while keyboard buffer alone remains untouched.



Dave Pearson

2004-06-17, 8:55 pm

Xref: 127.0.0.1 comp.lang.clipper:4714

* AUGE_OHR <AUGE_OHR@CSI.COM>:

> did you run the Sample ?
> NextKey() return "all" char which was stuff into KEYBOARD.
> (this is why i use CHR(NextKey()) to verify my cString)


In your sample NEXTKEY() doesn't return all of the characters; your use of
INKEY() in the loop is what gives that effect. NEXTKEY() only gives you the
next available character:

,----[ From the CA-Clipper manual ]
| NEXTKEY() is like the INKEY() function, but differs in one fundamental
| respect. INKEY() removes the pending key from the keyboard buffer and
| updates LASTKEY() with the value of the key. NEXTKEY(), by contrast, reads,
| but does not remove the key from the keyboard buffer and does not update
| LASTKEY().
`----

--
Dave Pearson | OSLib - Timeslice release functions.
http://www.davep.org/ | eg - Norton Guide reader for Linux.
http://www.davep.org/clipper/ | weg - Norton Guide reader for Windows.
http://www.davep.org/norton-guides/ | dgscan - DGROUP scanner for Clipper.
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com