Page 1 of 1

Change log file

Posted: Wed Oct 26, 2011 6:29 am
by omni
Roger,

We have a few major files that we keep track of certain fields, when they are updated, by whom, and retain in a history by reference, thus allowing users to see who changed what and when.
Our larger users want this for all master files, employees, customers,etc. There are probably a dozen files involved with anywhere from 15-50 fields each. Have you seen a method to check the fields before and after to see if changed without going thru the tedious code to check each var against the field, one by one, and recording in the history log. These programs, some written last century originally, have programmer defined variables, many added and deleted over the years.

Thanks

Fred
Omni

Re: Change log file

Posted: Wed Oct 26, 2011 8:39 am
by rdonnay
I'm not sure how to answer this.

I would probably use Scatter() to Scatter the fields into an array and them use DC_ACompare() to compare the arrays.

Code: Select all

aArray1 := CUSTOMER->(Scatter())

.. modify record

aArray2 := CUSTOMER->(Scatter())

IF !DC_ACompare( aArray1, aArray2)
  DCMSGBOX 'Something has been changed!'
ENDIF

Re: Change log file

Posted: Wed Oct 26, 2011 4:37 pm
by RDalzell
Roger,

You have an example which performs this really well, dbnotify().

I put in my wish list the docs for it, appears to be the cure.

Rick

Re: Change log file

Posted: Wed Oct 26, 2011 8:27 pm
by rdonnay
Rick -

I forgot about that.
In fact, I even wrote a sample program:
\exp19\samples\dbnotify\dbnotify.prg

Thanks

Roger