XBrowse 9.2

XBrowse 9.2

Postby David Williams » Mon Mar 23, 2009 6:14 pm

Hi Everyone

oBrw:bLogicLen = {|| Saddocs->(ordkeycount()) }

Is this statement now redundant? I noticed that if I use it, I get an extra column in the browse with the heading BLOGICLEN and the number of records.

Thanks,
David
User avatar
David Williams
 
Posts: 82
Joined: Fri Mar 03, 2006 6:26 pm
Location: Ireland

Re: XBrowse 9.2

Postby Antonio Linares » Mon Mar 23, 2009 11:42 pm

David,

What FWH version were you using previously to 9.02 ?
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 41435
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: XBrowse 9.2

Postby nageswaragunupudi » Tue Mar 24, 2009 1:20 am

XBrowse never had a DATA bLogicLen. This data is used by WBrowse.

In XBrowse the DATA bKeyCount servers the same purpose.

From version 8.07, any assignment like :
oBrw:<somename> := <somecodeblock> adds a new column with Header as <somename> and bEditValue as <somecodeblock>.

Please see item 7 of whats new in July 2008, reproduced below:
7. In earlier versions a column object can be retrieved by oBrw:oCol( <cHeader> ). Now it is possible to retrieve a
column object with new syntax oBrw:cHeader. It is also possible to create new columns with this syntax.

Example:
oBrw:SalePrice := { || oBrw:Sales:Value / oBrw:Quantity:Value }
Above stament adds a new column with the header 'SALEPRICE' whose value is the value of column with header 'SALES'
divided by the value in the column with header 'QUANTITY'.
oBrw:Sales:nEditType := EDIT_GET
Column with header 'SALES' is set to editmode.

This allows us to write very short self documented as well as highly portable code to create new columns.
Here is an example
Code: Select all  Expand view

#include "fivewin.ch"
#include "xbrowse.ch"

function main()

   local oWnd, oBrw, cAlias
   local nSource

   nSource := Alert( "DataSource", { "DBF", "Access" } )

   if nSource == 1
      cAlias := OpenDBF()
   elseif nSource == 2
      cAlias := OpenAccess()
   else
      return nil
   endif

   DEFINE WINDOW oWnd

   @ 0,0 XBROWSE oBrw OF oWnd ;
      COLUMNS "Last", "Age", "Salary" ;
      ALIAS cAlias

   // now i want to create a new column
   // which is Salary / Age

   oBrw:Ratio := { || oBrw:Salary:Value / oBrw:Age:Value }

   // Advantages:
   // Purpose of the code is very clear.
   // Also the code is very portable
   // Same code works for DBF or ADO
   // without any modification

   // Browse code does not have any code specific to the datasource

   oBrw:CreateFromCode()
   oWnd:oClient := oBrw

   ACTIVATE WINDOW oWnd

return nil

static function OpenDBF()

   USE \FWH\SAMPLES\CUSTOMER ALIAS CUST

return "CUST"

static function OpenAccess()

   local oCon, oRs
   local cStr   := "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + ;
            "c:\fwh\samples\xbrtest.mdb;User Id=admin;Password=;"

   oCon                     := TOleAuto():new("ADODB.Connection")
   oCon:ConnectionString   := cStr
   TRY
      oCon:Open()
   CATCH
      MsgInfo('Connect Fail')
      QUIT
   END

   oRs                     := TOleAuto():new( "ADODB.RecordSet" )
   oRs:ActiveConnection    := oCon
   oRs:Source              := 'CUSTOMER'
   oRs:LockType            := 4            // adLockOptimistic
   oRs:CursorLocation      := 3            //adUseClient
   oRs:CacheSize           := 100
   TRY
      oRs:Open()
   CATCH
      MsgStop('Access Table Open Failure')
      QUIT
   END

return oRs
 


Now you can understand why XBrowse is creating a new column with Header bLogicLen.
Regards

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

Re: XBrowse 9.2

Postby David Williams » Wed Mar 25, 2009 8:14 am

Antonio and G

I previously used TCBrowse from Luis Klaus Mantilla and I'm converting to xBrowse. Thank you for the full explanation.

Regards
David
User avatar
David Williams
 
Posts: 82
Joined: Fri Mar 03, 2006 6:26 pm
Location: Ireland

Re: XBrowse 9.2

Postby nageswaragunupudi » Wed Mar 25, 2009 8:18 am

If you are converting TCBrowse to TXbrowse, if you stick to Command syntax, the conversion will be pretty fast and reliable. Saves lot of develpment time. Command syntax of TCBrowe and TXBrowse are purposefully made similar for that reason.

Also you can remove lot of old code if you use the extended builtin features of XBrowse. It is less code and more work with XBrowse.
Regards

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


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 30 guests