on change for get

on change for get

Postby patili » Fri May 18, 2007 8: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
User avatar
patili
 
Posts: 98
Joined: Mon Jan 23, 2006 9:34 am
Location: LE CREUSOT FRANCE

Postby James Bott » 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
User avatar
James Bott
 
Posts: 4840
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA

Postby patili » 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?
User avatar
patili
 
Posts: 98
Joined: Mon Jan 23, 2006 9:34 am
Location: LE CREUSOT FRANCE

Postby James Bott » Sat May 19, 2007 6: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
User avatar
James Bott
 
Posts: 4840
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA

Postby patili » 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
User avatar
patili
 
Posts: 98
Joined: Mon Jan 23, 2006 9:34 am
Location: LE CREUSOT FRANCE

Postby patili » Sun May 20, 2007 8: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
User avatar
patili
 
Posts: 98
Joined: Mon Jan 23, 2006 9:34 am
Location: LE CREUSOT FRANCE

Postby James Bott » Mon May 21, 2007 9:17 pm

I am glad to hear you got it working.

Regards,
James
User avatar
James Bott
 
Posts: 4840
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA


Return to FiveWin for CA-Clipper

Who is online

Users browsing this forum: No registered users and 6 guests