/*
Purpose : Showing how to build database object classes
Also shows inheritance from a base class
Program :
Author : James Bott, jbott@compuserve.com
Date : 10/29/2018 11:42:51 AM
Company : Intellitech
Copyright: Copyright © 2018 Intellitech. All rights reserved.
Language : Fivewin/xHarbour
Updated :
Notes :
*/
#include "fivewin.ch"
Function Main()
Local oCustomers
Local oInvoices
REQUEST DBFCDX
rddsetdefault( "DBFCDX" )
SET EXCLUSIVE OFF
SET(_SET_AUTOPEN, .T. ) // Auto open cdx-index files
BuildIndexes()
oCustomers := TCustomers():new()
oCustomers:skip(10)
msgInfo(oCustomers:last) // Shows Farley
oCustomers:last := "Farley 2" // change
oCustomers:save() // save
msgInfo(oCustomers:last) // Shows "Farley 2"
oCustomers:last := "Farley"
oCustomers:save()
select(oCustomers:nArea)
browse() // Shows Farley
Return nil
//---------------------------------------------------------------------------//
// Base class for DBF classes
Class TXData from TDatabase
Method New()
Endclass
Method New(cFile,lShared) CLASS TXData
Default lShared := .t.
::super():New(,cFile,,lShared)
::use()
Return self
//---------------------------------------------------------------------------//
Class TCustomers from TXData
Method New()
Endclass
Method New(lShared) CLASS TCustomers
::super:New("customer", lShared)
Return self
//---------------------------------------------------------------------------//
Class TInvoice from TXData
Method New()
Endclass
Method New(lShared) CLASS TInvoice
::super:New("Invoice", lShared)
Return self
*/
//---------------------------------------------------------------------------//
Function BuildIndexes()
use customer
Index on "id" tag "custno" to customer
index on "last" tag "last" to customer
close
// use invoice
// index on "last" tag "Invno" to invoice
// close
RETURN NIL
USE Customer
DATABASE oDbf
oCustomers := TCustomers():new()
oCustomers:last := "Farley 2" // change
oCustomers:save() // save
msgInfo(oCustomers:last) // Shows "Farley 2"
oCustomer:= TCustomer():New()
..
CLASS TCustomer from TDatabase
Method New()
Endclass
Method New() CLASS TCustomer
Super:New(,"customer","DBFCDX",.t.)
::use()
// Note: Since you are using DBFCDX, the index file is automatically opened
// and the first index is selected and it is at the first record.
Return self
1) Tdatabase of fwh run ok or have problems ? or I must use another tdatabase on commerce..
2) Seeing your source I saw you create at init the index of archives when the app is opened then call
oCustomers := TCustomers():new()
but Tcustomer class is linked to another class called Txdata
why this ? why not make a link directly to tdatabase class ?
Class TCustomers from TXData
Method New()
Endclass
Method New(lShared) CLASS TCustomers
Default lShared := .t.
::super:New("customer", lShared)
::use()
Return self
Default lShared := .t.
::use()
I understood you change the name " FArley" into "Farley 2" because then you call oCustomer:save().
But then when I see the message I see "Farley 2" but then on the browse I see allways "Farley" and not "Farley 2"
oCustomers:last := "Farley"
oCustomers:save()
What is the difference between calling txdata or calling tdatabase directly?
I must open and manage this file at the same mode ( txdata) or I must open it on esclusive mode ?
Enrico Maria Giordano wrote:Probably you are using the new CDX with the old DBF. Try to rebuild the CDX.
EMG
Return to FiveWin for Harbour/xHarbour
Users browsing this forum: Google [Bot] and 42 guests