Page 1 of 1

Subclass Xbrowse or changed data function

PostPosted: Thu Sep 08, 2022 8:47 am
by Marc Venken
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.

Re: Subclass Xbrowse or changed data function

PostPosted: Thu Sep 08, 2022 7:24 pm
by nageswaragunupudi
Only one line of code
Code: Select all  Expand view
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

Re: Subclass Xbrowse or changed data function

PostPosted: Thu Sep 08, 2022 9:50 pm
by Otto
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

Re: Subclass Xbrowse or changed data function

PostPosted: Fri Sep 09, 2022 1:55 am
by nageswaragunupudi
If an error occurs while saving data to the DBF, bOnChange also is not executed.

Re: Subclass Xbrowse or changed data function

PostPosted: Fri Sep 09, 2022 5:33 am
by Otto
Dear Mr. Rao,
Therefore, I thought Mark should first save the old data before saving the new.

Best regards,
Otto

Re: Subclass Xbrowse or changed data function

PostPosted: Fri Sep 09, 2022 1:58 pm
by nageswaragunupudi
There is nothing special he has to do.
Just keep using XBrowse as it is.