I would parse both fields into the same array like this:

repeat for each line tLine in field "lastWeek"
   put item 4 of tLine into tArray[item 1 of tLine,item 2 of tLine,item 3 of 
tLine]["lastWeek"]
end repeat

repeat for each line tLine in field "thisWeek"
   put item 4 of tLine into tArray[item 1 of tLine,item 2 of tLine,item 3 of 
tLine]["thisWeek"]
end repeat

repeat for each key tKey in tArray
   put tArray[tKey]["thisWeek"] - tArray[tKey]["lastWeek"] into tDifference
   -- format the report line how you like here
end repeat

Cheers

Monte

On 02/09/2013, at 8:36 PM, "John Allijn" <john.allijn...@gmail.com> 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

--
Monte Goulding

M E R Goulding - software development services
mergExt - There's an external for that!





_______________________________________________
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