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
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
David,
What FWH version were you using previously to 9.02 ?
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:Value / oBrw: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: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 oRsAntonio and G
I previously used TCBrowse from Luis Klaus Mantilla and I'm converting to xBrowse. Thank you for the full explanation.
Regards
David
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.