Alaska Software Inc. - LastKey()
Username: Password:
AuthorTopic: LastKey()
JorgeLastKey()
on Tue, 01 Jul 2008 21:31:12 -0300
hello to all

my problem is that the LastKey() still loaded and do not remove the value of 
the buffers.
How i can empty the buffer () of the keyboard in order that I do not still 
have the LastKey() loaded ?

i need check the keypressed  in UDF of achoice()
i can't to use the folow example beacouse it wait a keypressed into the UDF 
and Achoice() not work !

while nk != 0
  nk :=inkey( 0.1 )
enddo

regards
Zupan Miran Re: LastKey()
on Wed, 02 Jul 2008 08:54:12 +0200
Jorge pravi:
> hello to all
> 
> my problem is that the LastKey() still loaded and do not remove the value of 
> the buffers.
> How i can empty the buffer () of the keyboard in order that I do not still 
> have the LastKey() loaded ?
> 
> i need check the keypressed  in UDF of achoice()
> i can't to use the folow example beacouse it wait a keypressed into the UDF 
> and Achoice() not work !
> 
> while nk != 0
>   nk :=inkey( 0.1 )
> enddo
> 
> regards
> 
> 
> 

Maybe something like this

    FUNCTION Tipka_Nazaj()
      CLEAR TYPEAHEAD
      KEYBOARD Chr(K_ESC)
    RETURN nil

... or.
    FUNCTION Type_V; CLEAR TYPEAHEAD; KEYBOARD "V"; RETURN nil    /* Vnos novega zapisa    */
    FUNCTION Type_S; CLEAR TYPEAHEAD; KEYBOARD "S"; RETURN nil    /* Spremeni zapis        */

... in browse ...
WHILE .T.
   oBrowse:colorRect({oBrowse:rowPos, oBrowse:freeze +1, oBrowse:rowPos, oBrowse:colCount}, {1,1})
   oBrowse:Forcestable()
   oBrowse:colorRect({oBrowse:rowPos, oBrowse:freeze +1, oBrowse:rowPos, oBrowse:colCount}, {2,3})
   oBrowse:hilite()
   IF ( oBrowse:stable )
      IF ( oBrowse:hitTop .OR. oBrowse:hitBottom )
--->        CLEAR TYPEAHEAD   <---
      ENDIF
      nKey := INKEY(0)

      //*** lastne funkcije v programu ***
      do case
          case nKey = K_ALT_S .or. nKey = K_ENTER .or. chr(nKey)="S"
               edit_ddv(.F.)
               oBrowse:refreshCurrent()

          case nKey = K_ALT_V .or. chr(nKey)="V"
               edit_ddv(.T.)
               if LastAppEvent()=xbeK_ESC
                  go top
               endif
               oBrowse:refreshAll()

          case nKey = K_ALT_B .or. chr(nKey)="B"
               Brisi_zapis()
               oBrowse:refreshAll()

       endcase
  ENDIF
  IF !TBMoveCursor( nKey, oBrowse )
     IF ( nKey == K_ESC )
         EXIT
     ENDIF
  ENDIF
END


regards
Zupan Miran
Slovenia
JorgeRe: LastKey()
on Wed, 02 Jul 2008 10:18:27 -0300
Hello Zupan
CLEAR TYPEAHEAD not work
but if execute Keyboard Chr( n ), only change the value of buffer and not 
solve the problem

than you very much for your advice

"Zupan Miran" <spczupan@spc-zupan.si> escribi en el mensaje 
news:16f8fdf1$1ff3268d$2db0@news.alaska-software.com...
> Jorge pravi:
>> hello to all
>>
>> my problem is that the LastKey() still loaded and do not remove the value 
>> of the buffers.
>> How i can empty the buffer () of the keyboard in order that I do not 
>> still have the LastKey() loaded ?
>>
>> i need check the keypressed  in UDF of achoice()
>> i can't to use the folow example beacouse it wait a keypressed into the 
>> UDF and Achoice() not work !
>>
>> while nk != 0
>>   nk :=inkey( 0.1 )
>> enddo
>>
>> regards
>>
>>
>>
>
> Maybe something like this
>
>    FUNCTION Tipka_Nazaj()
>      CLEAR TYPEAHEAD
>      KEYBOARD Chr(K_ESC)
>    RETURN nil
>
> ... or.
>    FUNCTION Type_V; CLEAR TYPEAHEAD; KEYBOARD "V"; RETURN nil    /* Vnos 
> novega zapisa    */
>    FUNCTION Type_S; CLEAR TYPEAHEAD; KEYBOARD "S"; RETURN nil    /* 
> Spremeni zapis        */
>
> ... in browse ...
> WHILE .T.
>   oBrowse:colorRect({oBrowse:rowPos, oBrowse:freeze +1, oBrowse:rowPos, 
> oBrowse:colCount}, {1,1})
>   oBrowse:Forcestable()
>   oBrowse:colorRect({oBrowse:rowPos, oBrowse:freeze +1, oBrowse:rowPos, 
> oBrowse:colCount}, {2,3})
>   oBrowse:hilite()
>   IF ( oBrowse:stable )
>      IF ( oBrowse:hitTop .OR. oBrowse:hitBottom )
> --->        CLEAR TYPEAHEAD   <---
>      ENDIF
>      nKey := INKEY(0)
>
>      //*** lastne funkcije v programu ***
>      do case
>          case nKey = K_ALT_S .or. nKey = K_ENTER .or. chr(nKey)="S"
>               edit_ddv(.F.)
>               oBrowse:refreshCurrent()
>
>          case nKey = K_ALT_V .or. chr(nKey)="V"
>               edit_ddv(.T.)
>               if LastAppEvent()=xbeK_ESC
>                  go top
>               endif
>               oBrowse:refreshAll()
>
>          case nKey = K_ALT_B .or. chr(nKey)="B"
>               Brisi_zapis()
>               oBrowse:refreshAll()
>
>       endcase
>  ENDIF
>  IF !TBMoveCursor( nKey, oBrowse )
>     IF ( nKey == K_ESC )
>         EXIT
>     ENDIF
>  ENDIF
> END
>
>
> regards
> Zupan Miran
> Slovenia
Christian Laborde Re: LastKey()
on Wed, 02 Jul 2008 16:25:03 +0200
The solution is in the documentation :

The functions Inkey(), LastKey() and NextKey() are used for retrieving keyboard 
input. Inkey() reads the next keypress and removes it from the keyboard buffer. 
NextKey() reads the next keypress without removing it from the keyboard buffer. 
LastKey() returns the last keypress removed from the keyboard buffer.

Regards

Jorge a écrit :
> Hello Zupan
> CLEAR TYPEAHEAD not work
> but if execute Keyboard Chr( n ), only change the value of buffer and not 
> solve the problem
> 
> than you very much for your advice
> 
> "Zupan Miran" <spczupan@spc-zupan.si> escribió en el mensaje 
> news:16f8fdf1$1ff3268d$2db0@news.alaska-software.com...
>> Jorge pravi:
>>> hello to all
>>>
>>> my problem is that the LastKey() still loaded and do not remove the value 
>>> of the buffers.
>>> How i can empty the buffer () of the keyboard in order that I do not 
>>> still have the LastKey() loaded ?
>>>
>>> i need check the keypressed  in UDF of achoice()
>>> i can't to use the folow example beacouse it wait a keypressed into the 
>>> UDF and Achoice() not work !
>>>
>>> while nk != 0
>>>   nk :=inkey( 0.1 )
>>> enddo
>>>
>>> regards
>>>
>>>
>>>
>> Maybe something like this
>>
>>    FUNCTION Tipka_Nazaj()
>>      CLEAR TYPEAHEAD
>>      KEYBOARD Chr(K_ESC)
>>    RETURN nil
>>
>> ... or.
>>    FUNCTION Type_V; CLEAR TYPEAHEAD; KEYBOARD "V"; RETURN nil    /* Vnos 
>> novega zapisa    */
>>    FUNCTION Type_S; CLEAR TYPEAHEAD; KEYBOARD "S"; RETURN nil    /* 
>> Spremeni zapis        */
>>
>> ... in browse ...
>> WHILE .T.
>>   oBrowse:colorRect({oBrowse:rowPos, oBrowse:freeze +1, oBrowse:rowPos, 
>> oBrowse:colCount}, {1,1})
>>   oBrowse:Forcestable()
>>   oBrowse:colorRect({oBrowse:rowPos, oBrowse:freeze +1, oBrowse:rowPos, 
>> oBrowse:colCount}, {2,3})
>>   oBrowse:hilite()
>>   IF ( oBrowse:stable )
>>      IF ( oBrowse:hitTop .OR. oBrowse:hitBottom )
>> --->        CLEAR TYPEAHEAD   <---
>>      ENDIF
>>      nKey := INKEY(0)
>>
>>      //*** lastne funkcije v programu ***
>>      do case
>>          case nKey = K_ALT_S .or. nKey = K_ENTER .or. chr(nKey)="S"
>>               edit_ddv(.F.)
>>               oBrowse:refreshCurrent()
>>
>>          case nKey = K_ALT_V .or. chr(nKey)="V"
>>               edit_ddv(.T.)
>>               if LastAppEvent()=xbeK_ESC
>>                  go top
>>               endif
>>               oBrowse:refreshAll()
>>
>>          case nKey = K_ALT_B .or. chr(nKey)="B"
>>               Brisi_zapis()
>>               oBrowse:refreshAll()
>>
>>       endcase
>>  ENDIF
>>  IF !TBMoveCursor( nKey, oBrowse )
>>     IF ( nKey == K_ESC )
>>         EXIT
>>     ENDIF
>>  ENDIF
>> END
>>
>>
>> regards
>> Zupan Miran
>> Slovenia 
> 
> 


Christian Laborde
La Révolution citoyenne, c'est sur : http://c.lab.over-blog.com/
Le forum des électrons libres : http://electrons-libres.forumactif.fr
True E-mail : remove -no-spam-
Rte de la Conversion, 20
CH 1095 Lutry
Suisse
JorgeRe: LastKey()
on Wed, 02 Jul 2008 14:23:15 -0300
Chritian, Carlos thanks for your advice
>     FUNCTION Tipka_Nazaj()
>       CLEAR TYPEAHEAD
>       InKey()
>     RETURN nil
Inkey() empty his own buffer, but it does not do it for the lastkey()

the problem is that i have my own dbedit and achoice that check the inkey() 
code, and when enter to my UDF, the inkey() was empty() and lastkey() not, 
then i pass to UDF the inkey() read into my achoice() and solved !

thank a lot
Preview Re: LastKey()
on Wed, 02 Jul 2008 12:00:59 -0300
Does the below work?
     FUNCTION Tipka_Nazaj()
       CLEAR TYPEAHEAD
       InKey()
     RETURN nil
Christian Laborde Re: LastKey()
on Wed, 02 Jul 2008 18:03:25 +0200
CLEAR TYPEAHEAD has no effect on LastKey()

Regards

Preview a écrit :
>  Does the below work?
>     FUNCTION Tipka_Nazaj()
>       CLEAR TYPEAHEAD
>       InKey()
>     RETURN nil


Christian Laborde
La Révolution citoyenne, c'est sur : http://c.lab.over-blog.com/
Le forum des électrons libres : http://electrons-libres.forumactif.fr
True E-mail : remove -no-spam-
Rte de la Conversion, 20
CH 1095 Lutry
Suisse