Autoincremental search of Numeric field in xBrowse

Post Reply
User avatar
Maurizio
Posts: 826
Joined: Mon Oct 10, 2005 1:29 pm
Contact:

Autoincremental search of Numeric field in xBrowse

Post by Maurizio »

Is it possible seek Numeric field with xBrowse ?

Regards MAurizio
User avatar
nageswaragunupudi
Posts: 10721
Joined: Sun Nov 19, 2006 5:22 am
Location: India
Been thanked: 8 times
Contact:

Post by nageswaragunupudi »

Yes.

We need to write the appropriate seek function and assign it as codeblock to oBrw:bSeek. We can do anything we want with this codeblock.
Regards

G. N. Rao.
Hyderabad, India
User avatar
Maurizio
Posts: 826
Joined: Mon Oct 10, 2005 1:29 pm
Contact:

Post by Maurizio »

Hello
I change the Method Seek() and now works

* if !Eval( ::bSeek, cSeek )
* Eval( ::bBookMark, uBook )
* MsgBeep()
* return nil
* endif

Select (::cAlias)
cOrderType := Valtype(& ("field->" + ( ::cAlias )->( OrdKey() ) ))
if !Eval( ::bSeek, iif(cOrderType == "N", val(cSeek) , cSeek ))
IF cOrderType == "N"
::cSeek := cSeek
ELSE
MsgBeep()
ENDIF
Eval( ::bBookMark, uBook )
return nil
endif

Regards MAurizio
User avatar
nageswaragunupudi
Posts: 10721
Joined: Sun Nov 19, 2006 5:22 am
Location: India
Been thanked: 8 times
Contact:

Post by nageswaragunupudi »

It can be done without changing xbrowse library code. And I personally prefer writing the code without touching library code generally.

This is all what is needed ( I am using softseek )

Code: Select all | Expand

   oBrw:bSeek  := { |cSeek| CUST->( DbSeek( Val( cSeek ), .t. ), !eof() ) }
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
Posts: 10721
Joined: Sun Nov 19, 2006 5:22 am
Location: India
Been thanked: 8 times
Contact:

Post by nageswaragunupudi »

This is a sample code. This sample also shows the value being sought

Code: Select all | Expand

#include 'fivewin.ch'
#include 'xbrowse.ch'

REQUEST DBFCDX

function Main()

   local oDlg, oBrw
   local oSeek, cSeek := Space(25)

   USE CUSTOMER NEW ALIAS CUST SHARED VIA 'DBFCDX'
   SET ORDER TO TAG SALARY
   GO TOP

   DEFINE DIALOG oDlg SIZE 540,480 PIXEL

   @  10, 10 XBROWSE oBrw ;
      COLUMNS 'First','Last','Salary' ;
      SIZE 250,200 PIXEL ;
      OF oDlg ;
      ALIAS 'CUST' ;
      AUTOSORT

   @ 220, 10 SAY oSeek VAR cSeek SIZE 100,10 PIXEL OF oDlg ;
         COLOR CLR_BLACK, CLR_YELLOW

   oBrw:bSeek  := { |cSeek| CUST->( DbSeek( Val( cSeek ), .t. ), !eof() ) }
   oBrw:oSeek  := oSeek

   oBrw:CreateFromCode()

   ACTIVATE DIALOG oDlg CENTERED

return nil

We can seek any data type, without modifying the xbrowse source code.
Regards

G. N. Rao.
Hyderabad, India
User avatar
Maurizio
Posts: 826
Joined: Mon Oct 10, 2005 1:29 pm
Contact:

Post by Maurizio »

Thank NageswaraRao
I try your sample , it works but only on the numeric Col. If you have two Col ( one numeric and one character ) and you need both seek
doesn't works .

Maurizio
User avatar
nageswaragunupudi
Posts: 10721
Joined: Sun Nov 19, 2006 5:22 am
Location: India
Been thanked: 8 times
Contact:

Post by nageswaragunupudi »

Maurizio wrote:Thank NageswaraRao
I try your sample , it works but only on the numeric Col. If you have two Col ( one numeric and one character ) and you need both seek
doesn't works .

Maurizio


True
I gave the sample to demonstrate that XBrowse lets us do the real code to Seek. We need to code how do we seek the value entered by suitably coding the bSeek codeblock and not by changing the XBrowse source code.

Sure we can write more generic code.
Regards

G. N. Rao.
Hyderabad, India
Post Reply