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
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.
#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
Return to FiveWin for Harbour/xHarbour
Users browsing this forum: No registered users and 86 guests