FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour Autoincremental search of Numeric field in xBrowse
Posts: 842
Joined: Mon Oct 10, 2005 01:29 PM
Autoincremental search of Numeric field in xBrowse
Posted: Fri Aug 29, 2008 10:05 AM

Is it possible seek Numeric field with xBrowse ?

Regards MAurizio

Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Autoincremental search of Numeric field in xBrowse
Posted: Sat Aug 30, 2008 01: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
Posts: 842
Joined: Mon Oct 10, 2005 01:29 PM
Autoincremental search of Numeric field in xBrowse
Posted: Sat Aug 30, 2008 02: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

Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Autoincremental search of Numeric field in xBrowse
Posted: Sat Aug 30, 2008 02: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 )
   oBrw:bSeek  := { |cSeek| CUST->( DbSeek( Val( cSeek ), .t. ), !eof() ) }
Regards



G. N. Rao.

Hyderabad, India
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Autoincremental search of Numeric field in xBrowse
Posted: Sat Aug 30, 2008 03:10 PM
This is a sample code. This sample also shows the value being sought
#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
Posts: 842
Joined: Mon Oct 10, 2005 01:29 PM
Autoincremental search of Numeric field in xBrowse
Posted: Mon Sep 01, 2008 06: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

Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Autoincremental search of Numeric field in xBrowse
Posted: 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

Continue the discussion