Dimensional Arrays

Ken Ray kray at sonsothunder.com
Thu Mar 15 02:11:11 EDT 2007


On Wed, 14 Mar 2007 17:11:36 +0200, Nic Prioleau wrote:

> Hi Kev,
> 
> Thanks for your feedback however, I managed to get something like this:
> 
> regNo,totalFuel,totalKM,month
> B456TRF,1000,0,2
> B456TRF,150,0,3
> B456TRF,0,376,3
> B444AAA,50,0,3
> B444AAA,340,3000,3
> B444AAA,0,600,3
> 
> into a variable from my selects... Could you tell me how I can 
> achieve the same result as I was trying to get before as I have now 
> eliminated the other arrays I had. It was too messy and because they 
> did not have the same keys, it was difficult to get an accurate 
> result.

Basically the same thing, but it's actually easier in this case - you 
can take the variable and filter on the regNo (put an asterisk after 
the regno so there'll be a match):

  filter tData with "B444AAA*"

And then loop through the resulting filtered lines, extract the items 
you're looking for an add them up:

put 0 into tLitres
put 0 into tKMs
repeat for each line tLine in tData
  add (item 2 of tLine) to tLitres
  add (item 3 of tLine) to tKMs
end repeat

HTH,

Ken Ray
Sons of Thunder Software, Inc.
Email: kray at sonsothunder.com
Web Site: http://www.sonsothunder.com/



More information about the use-livecode mailing list