Autoincremental search of Numeric field in xBrowse

Autoincremental search of Numeric field in xBrowse

Postby Maurizio » Fri Aug 29, 2008 10:05 am

Is it possible seek Numeric field with xBrowse ?

Regards MAurizio
User avatar
Maurizio
 
Posts: 824
Joined: Mon Oct 10, 2005 1:29 pm

Postby nageswaragunupudi » Sat Aug 30, 2008 1:56 pm

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
nageswaragunupudi
 
Posts: 10624
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Postby Maurizio » Sat Aug 30, 2008 2:19 pm

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
Maurizio
 
Posts: 824
Joined: Mon Oct 10, 2005 1:29 pm

Postby nageswaragunupudi » Sat Aug 30, 2008 2:21 pm

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 view
   oBrw:bSeek  := { |cSeek| CUST->( DbSeek( Val( cSeek ), .t. ), !eof() ) }
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10624
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Postby nageswaragunupudi » Sat Aug 30, 2008 3:10 pm

This is a sample code. This sample also shows the value being sought
Code: Select all  Expand view
#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
nageswaragunupudi
 
Posts: 10624
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Postby Maurizio » Mon Sep 01, 2008 6:56 am

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
Maurizio
 
Posts: 824
Joined: Mon Oct 10, 2005 1:29 pm

Postby nageswaragunupudi » Mon Sep 01, 2008 10:54 am

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
User avatar
nageswaragunupudi
 
Posts: 10624
Joined: Sun Nov 19, 2006 5:22 am
Location: India


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: Google [Bot] and 49 guests