<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
  <meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
If you have 32 "line items" with 5 fields per line item then you would
have a loop of between 1 and 160.&nbsp; Add the offset for the file record
comparison.&nbsp; (IOW, if the line-items start at field 10 then loop
between "1" and "160" and add "10" to the fields you are comparing.)&nbsp;
To find out which line item you are dealing with simply divide the
current instance of the loop by 5 and the integer is the particular
line-item you're dealing with.&nbsp; To find out which field then enter a
line something like this:<br>
<br>
aa=MOD(n,"5")+"1"<br>
<br>
Where 'n' is the instance in the loop.&nbsp; 'aa' will hold a number between
"1" and "5".<br>
<br>
The idea of copying a file was documented in the FilePro manual under
"Clone Files" in "Advanced Concepts" under the "How Do I" section.&nbsp; <br>
<br>
Here is a copy of the text:<br>
<br>
<br>
Clone Files<br>
<br>
Big Hint: Making a clone file can save your act. Keep an audit trail of
everything that happens to a particular data set. If you have ever had
a user tell you &#8220;I didn&#8217;t do that&#8230;&#8221; and you can see that they were the
last person to update the file, it makes for a difficult session. You
&#8220;think&#8221; they might have been the one, but you can&#8217;t say for sure. Here
is the solution. On the files where you have this kind of trouble, or
on any file for which you want to keep accurate track of every change,
do the following: store exactly what happens to each field of the
record from the time it is created; every single change along with
date/time/user stamp. You will never have to guess again.<br>
<br>
The idea is simple and it can be carried out in a variety of ways. Here
is how I do it. <br>
<br>
1. Build a &#8220;logging file&#8221; to capture the log information. This file
should have fields for containing the filename, the process name, the
field #, the unique ref # for the record, the original data, the
changed data and the date/time/who for any file you wish to track. The
original data field and changed data field should be 79 characters
long. Call this file something like &#8220;myprefixlog&#8221;.<br>
<br>
2. First, I copy the file I wish to track with &#8220;fpcopy&#8221;. Only the file
structure is necessary, nothing else. Give the new file the name
&#8220;oldfilename.l&#8221; for &#8220;log&#8221;.<br>
<br>
3. Next, build an array in the &#8220;input&#8221; table of the file to be tracked
that contains every record in the file.<br>
<br>
&nbsp;&nbsp;&nbsp; Dim clone[#]:1<br>
<br>
Where # is the number of fields in the file. <br>
<br>
4. Whenever there is a possibility that fields may change, do a lookup
free to filename.1 and build a similar array over that file and
immediately copy the original file/record to the clone file/record.<br>
<br>
5. When the record is finally stored, compare the two arrays element by
element. If any field has changed, write the original value, the
changed value and the date/time/who into your actual log file
(myprefixlog).<br>
<br>
6. By indexing &#8220;myprefixlog&#8221; correctly, you can instantly see every
change in chronological order for any file.<br>
<br>
Here is an example of this code. Your values would have to change to
suit one of your own files.<br>
<br>
This snippet has to be &#8220;atomically&#8221; close to the real END statement of
your processing table.<br>
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; If: clone<br>
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Then: gosub changed<br>
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; If:<br>
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Then: end<br>
<br>
As soon as there is a chance that some fields may change, you must get
the free record in the clone file. This is a simple gosub.<br>
<br>
<br>
@keyU&nbsp; if:<br>
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; then: gosub clonit<br>
<br>
The actual cloning code looks like this:<br>
<br>
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; If:<br>
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Then: lookup clone=npio r=free &#8211;e<br>
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; If:<br>
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Then: copy clone<br>
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; If:<br>
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Then: dim before[566]:clone(1) ; write clone<br>
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; If:<br>
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Then: c(8,.0)=clone(@rn) ; return<br>
<br>
<br>
Jeff Harrison wrote:
<blockquote cite="mid47489.94791.qm@web50712.mail.yahoo.com" type="cite">
  <pre wrap="">--- Boaz Bezborodko <a class="moz-txt-link-rfc2396E" href="mailto:boaz@mirrotek.com">&lt;boaz@mirrotek.com&gt;</a> wrote:

  </pre>
  <blockquote type="cite">
    <blockquote type="cite">
      <blockquote type="cite">
        <pre wrap="">I believe that he wants to compare the current
        </pre>
      </blockquote>
    </blockquote>
    <pre wrap="">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.
    </pre>
    <pre wrap="">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.  When saving the record run
a loop to compare
each field with the same field in the qualified
record.  If you only
have to compare the item records then simply start
the loop at that
field.  A simple MOD statement will tell you which
of the detail items
of the associated fields you are dealing with.

When you're done you can delete the qualified
record.

Boaz

    </pre>
  </blockquote>
  <pre wrap=""><!---->
"simple MOD statement" ??  Can you give us some more
detail here?  

It sounds like there would be quite a bit more IO with
this approach - also, you mentioned that you would
still need a loop... still if it is simplier to code I
would be interested in hearing the details.

Jeff Harrison
<a class="moz-txt-link-abbreviated" href="mailto:jeffaharrison@yahoo.com">jeffaharrison@yahoo.com</a>

Author of JHExport and JHImport.  The fastest and
easiest ways to export and import Filepro data.


 
____________________________________________________________________________________
Don't pick lemons.
See all the new 2007 cars at Yahoo! Autos.
<a class="moz-txt-link-freetext" href="http://autos.yahoo.com/new_cars.html">http://autos.yahoo.com/new_cars.html</a> 

  </pre>
</blockquote>
</body>
</html>