FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour Subclass Xbrowse or changed data function
Posts: 1487
Joined: Tue Jun 14, 2016 07:51 AM

Subclass Xbrowse or changed data function

Posted: Thu Sep 08, 2022 08:47 AM

Using Xbrowse a lot, i'm thinking of the best way to register changes made in the xbrowse data.

A dbf with many fields is updated during the day and this for several fields. The changed data will be uploaded once a day true a API connection.

What do you do in this situation ?

I'm thinking of folowing

Make a changlog dbf where the changed data fields will be put in, and after API update clear this dbf

Name, olddata, newdata
adress, olddata, newdata
etc....

I can have Xbrowse do this for each field with the onchange , but then I have to code each field for this

My question : Can we subclass xbrowse for this to do automatic ? I never want a changed personel xbrowse for my projects because I want to keep all updates.
Maybe with a extra data: oBrw:logchanges -> Is true then log some fields
I never made a class, changed it or did any subclassing.

Marc Venken

Using: FWH 23.08 with Harbour
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM

Re: Subclass Xbrowse or changed data function

Posted: Thu Sep 08, 2022 07:24 PM
Only one line of code
Code (fw): Select all Collapse
oBrw:bOnChanges := <|oCol, uOldValue|
         FWLOG oCol:oBrw:BookMark, oCol:cExpr, uOldValue, oCol:Value
         return nil
         >

Instead of FWLOG, you can use your own write function
Regards



G. N. Rao.

Hyderabad, India
Posts: 6984
Joined: Fri Oct 07, 2005 07:07 PM

Re: Subclass Xbrowse or changed data function

Posted: Thu Sep 08, 2022 09:50 PM

Dear Mr. Rao,
Isn't that a little unsafe?

The data is changed first, and then the old ones are backed up.
What happens if an error occurs?
Best regards,
Otto

Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM

Re: Subclass Xbrowse or changed data function

Posted: Fri Sep 09, 2022 01:55 AM

If an error occurs while saving data to the DBF, bOnChange also is not executed.

Regards



G. N. Rao.

Hyderabad, India
Posts: 6984
Joined: Fri Oct 07, 2005 07:07 PM

Re: Subclass Xbrowse or changed data function

Posted: Fri Sep 09, 2022 05:33 AM

Dear Mr. Rao,
Therefore, I thought Mark should first save the old data before saving the new.

Best regards,
Otto

Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM

Re: Subclass Xbrowse or changed data function

Posted: Fri Sep 09, 2022 01:58 PM

There is nothing special he has to do.
Just keep using XBrowse as it is.

Regards



G. N. Rao.

Hyderabad, India

Continue the discussion