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.