Hi
I HAVE A PROBLEM WITH THE CHANGE IN GET
I use a twbrose in which the database is indexed on the name
I want use a get which will change the scope of the browse
When i GET "M" it must scope the data beginning by "M"
and if if enter "A" after it must scope the data beginning by "MA" etc etc..
I use "redefine get.. on change (newscope, refresh)" and it didn't work
when i enter "M" the buffer is empty and the scope didn't change
i must enter the second letter and the the scope is working on the first letter
The change is always one letter late
Any idea? Thanks
Sorry for my bad english
on change for get
- James Bott
- Posts: 4654
- Joined: Fri Nov 18, 2005 4:52 pm
- Location: San Diego, California, USA
- Contact:
Instead of bChange, use bPostKey. It is called like this in TGet.
Eval( ::bPostKey, Self, ::oGet:Buffer )
bChange is for use when you want to test the keystroke and either accept or reject it. If you return .t. from the codeblock the lastkey is accepted into the buffer, if you return .f. then the lastkey is not accepted.
bPostKey is eval'd after bChange so the lastkey will already be in the buffer.
James
Eval( ::bPostKey, Self, ::oGet:Buffer )
bChange is for use when you want to test the keystroke and either accept or reject it. If you return .t. from the codeblock the lastkey is accepted into the buffer, if you return .f. then the lastkey is not accepted.
bPostKey is eval'd after bChange so the lastkey will already be in the buffer.
James
- James Bott
- Posts: 4654
- Joined: Fri Nov 18, 2005 4:52 pm
- Location: San Diego, California, USA
- Contact:
Try this example.
James
--------------------
In order to use last char typed, let me suggest:
oGet:bChange:={|nKey| MyEval(oGet,nKey) }
Function MyEval(oGet,nKey)
Local cBuffer := oGet:oGet:Buffer
if nKey<>VK_RETURN
cBuffer := Stuff(cBuffer, ;
oGet:nPos,1,if(nKey=VK_BACK,'',chr(nKey))
// Now cBuffer contains the last char typed
// Do whatever here
return nil
James
--------------------
In order to use last char typed, let me suggest:
oGet:bChange:={|nKey| MyEval(oGet,nKey) }
Function MyEval(oGet,nKey)
Local cBuffer := oGet:oGet:Buffer
if nKey<>VK_RETURN
cBuffer := Stuff(cBuffer, ;
oGet:nPos,1,if(nKey=VK_BACK,'',chr(nKey))
// Now cBuffer contains the last char typed
// Do whatever here
return nil
Many thanks James
The stuff function generate allways a fatal error on my computer, but
with your help i've found everything that work well
local nkey:=lastkey()
local filtre:=""
.
.
.
redefine get g1 var nm id 105 picture "!A" of rep
g1:bChange:={|nkey| MyEval(g1,nkey,oBrowse,@filtre) }
.
.
.
.
Function MyEval(oGet,nKey,oBrowse,filtre)
Local cBuffer := oGet:oGet:Buffer
cbuffer:=if(nkey=19,"",upper(chr(nkey))) // all fields are uppercase
filtre:=filtre+cbuffer
re->(sx_setscope(0,filtre)) // I use hypersix
re->(dbgotop())
oBrowse:refresh()
return nil
Thanks
The stuff function generate allways a fatal error on my computer, but
with your help i've found everything that work well
local nkey:=lastkey()
local filtre:=""
.
.
.
redefine get g1 var nm id 105 picture "!A" of rep
g1:bChange:={|nkey| MyEval(g1,nkey,oBrowse,@filtre) }
.
.
.
.
Function MyEval(oGet,nKey,oBrowse,filtre)
Local cBuffer := oGet:oGet:Buffer
cbuffer:=if(nkey=19,"",upper(chr(nkey))) // all fields are uppercase
filtre:=filtre+cbuffer
re->(sx_setscope(0,filtre)) // I use hypersix
re->(dbgotop())
oBrowse:refresh()
return nil
Thanks
And now it work in the two directions
Function MyEval(oGet,nKey,l1,filtre)
Local cBuffer := oGet:oGet:Buffer
if nkey=8
filtre:=substr(filtre,1,len(filtre)-1)
else
cbuffer:=upper(chr(nkey))
filtre:=filtre+cbuffer
endif
re->(sx_setscope(0,filtre))
re->(dbgotop())
l1:refresh()
return nil
Thank Thank James
Function MyEval(oGet,nKey,l1,filtre)
Local cBuffer := oGet:oGet:Buffer
if nkey=8
filtre:=substr(filtre,1,len(filtre)-1)
else
cbuffer:=upper(chr(nkey))
filtre:=filtre+cbuffer
endif
re->(sx_setscope(0,filtre))
re->(dbgotop())
l1:refresh()
return nil
Thank Thank James
- James Bott
- Posts: 4654
- Joined: Fri Nov 18, 2005 4:52 pm
- Location: San Diego, California, USA
- Contact: