John,

How about something like (rough, untested pseudo-code) ....

put 1 into tLast
put 1 into tThis
put the number of lines in pLastWeek into countLast
put the number of lines in pThisWeek into countThis

repeat until the sun goes down  (I don't like to do "repeat forever ...")
   if tLast > countLast then  -- last week's is done
      if tThis > countThis then exit repeat   -- we're done
      -- every thing remaining in this week's report is new
      reportNew line tThis of pThisweek
      add 1 to tThis
      next repeat
   end if
   if tThis > countThis then   -- this week's is done, last week's isn't
     reportRemoved line tLast of pLastWeek
     add 1 to tLast
     next repeat
   end if
   if line tLast of pLastWeek = line tThis of pThisweek then next repeat
if item 1 to 2 of line tLast of pLastWeek = item 1 to 2 of line tThis of pThisweek then
        reportChanged line tLast of pLastWeek,  line tThis of pThisweek
        add 1 to tThis
        add 1 to tLast
        next repeat
   end if
if lineOffset( (CR & item 1 to 2 of line tLast of pLastWeek, line tThis to -1 of pThisWeek) > 0 then
       -- last week's line occurs later in this week's report
      reportNew line tThis of pThisweek
      add 1 to tThis
      next repeat
   end if
   -- last week's line doesn't appear - so it has been removed
   reportRemoved  line tLast of pLastWeek
   add 1 to tLast
end repeat

good luck ...
-- Alex.

On 02/09/2013 11:36, John Allijn wrote:
An automated system sends me weekly reports with the following structure:
Country,city,device_type,numer_of_devices
I'm working on an app that evaluates these reports and there is one thing I 
can't get done.
I'd like to compare this weeks report with that of last week and report changes.
Output could be something like this:
- UK-London - mobile - added 2 devices
- UAE - Dubai - new location - server - added 1
- FR - Paris - location removed - no more devices
- FR - Marseille - Location Added - mobile - 1 device added
- BE - brussels - no change


In my script I open both reports, copy the contents to two fields and with a 
loop I compare line by line of the two fields.
This works well as long as only the numbers change. When locations, cities or 
countries are added or deleted, the number of lines of both fields don't match 
anymore and my script doesnt work anymore.


There is potentially an unlimited number of countries, each with an unlimited 
number of cities that can be added or removed. I tried skipping a line and 
checking if that one matches with the next one in the other list, but obviously 
that didnt work. :(


Does anyone have an idea on how to approach this problem?



Thanks for any insights!!!
—
Sent from Mailbox for iPhone
_______________________________________________
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


_______________________________________________
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode

Reply via email to