Comparing record with original when saving - alternate

Wally Turnbull wally at tbull.com
Wed Jan 17 10:07:52 PST 2007


The thread was getting long so am top posting - sorry.

Several good solutions have been posted but I use the following variation
because I think it is faster as it does not do any I/O unless there is a
change.  It also allows one log file to monitor changes for any/all files.

This solution uses the variable pdat to hold the contents of all fields as
they were when the user pressed Update.

When the record is saved the logic does a gosub to VERLOG which checks for a
change to any field by comparing the current value of the field to the value
at that field's position in pdat.

If a field was changed a log entry is made to record the date, time,
file_name, field_name, previous_value, new_value, and username.

Indexes in the log file allow you to mix and match what you want to look at
later.

Peace,
Wally Turnbull


@UPDATE  If: '***********************************************************
  921  Then: '**** Run this when key U is pressed to update a record ****
         If: 
  922  Then: pdat=""; pnum="1";ppos="1"   'Clear to save original state
PREVB    If: 
  923  Then: mid(pdat,ppos,fieldlen(-,pnum)) = fieldval(-,pnum)
         If: pnum lt numfield(-)
  924  Then: ppos=ppos+fieldlen(-,pnum);pnum=pnum+"1";goto prevb
         If: 
  925  Then: screen; goto top

VERLOG   If: '***********************************************************
  926  Then: '********* Create Edit_Log entry of changed data ***********
         If: 'Compare old and new data on leaving record
  927  Then: 'and make a Edit_log entry if data was changed
         If: 
  928  Then: pnum="1"; ppos="1"
VERLOGB  If: mid(pdat,ppos,fieldlen(-,pnum)) ne fieldval(-,pnum)
  929  Then: gosub maklog    'changed - create log entry
         If: pnum lt numfield(-)
  930  Then: ppos=ppos+fieldlen(-,pnum);pnum=pnum+"1"; goto verlogb
VERLOGX  If: 
  931  Then: return

MAKLOG   If: 
  932  Then: '******** Create a logfile entry for changed field ********


---

Jeff Harrison wrote: 
--- Boaz Bezborodko <boaz at mirrotek.com> wrote:
  
I believe that he wants to compare the current
        
Values to the original values - if you want to do that at the time the
record is saved, then I believe that you do need an array to store the
original values.
    
The older Filepro manual has a solution for this
that doesn't use a lot of code.

What you do is create a qualifier for the file.  On
entering update copy the record to the qualified file and record the record
number of that record in a dummy field.  



More information about the Filepro-list mailing list