FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for CA-Clipper on change for get
Posts: 98
Joined: Mon Jan 23, 2006 09:34 AM
on change for get
Posted: Fri May 18, 2007 08:42 PM

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

Posts: 4840
Joined: Fri Nov 18, 2005 04:52 PM
on change for get
Posted: Fri May 18, 2007 10:40 PM

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

FWH 18.05/xHarbour 1.2.3/BCC7/Windows 10
Posts: 98
Joined: Mon Jan 23, 2006 09:34 AM
on change for get
Posted: Sat May 19, 2007 11:54 AM

Thanks
but in my FW 2.1 i don't have this bpostkey method

It always return
Error description: Error Objects/6 No Exp. Method: TGET:_BPOSTKEY

How can i do?

Posts: 4840
Joined: Fri Nov 18, 2005 04:52 PM
on change for get
Posted: Sat May 19, 2007 06:15 PM

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

FWH 18.05/xHarbour 1.2.3/BCC7/Windows 10
Posts: 98
Joined: Mon Jan 23, 2006 09:34 AM
on change for get
Posted: Sun May 20, 2007 10:03 AM

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

Posts: 98
Joined: Mon Jan 23, 2006 09:34 AM
on change for get
Posted: Sun May 20, 2007 08:05 PM

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

Posts: 4840
Joined: Fri Nov 18, 2005 04:52 PM
on change for get
Posted: Mon May 21, 2007 09:17 PM

I am glad to hear you got it working.

Regards,
James

FWH 18.05/xHarbour 1.2.3/BCC7/Windows 10

Continue the discussion