On 7/29/21 9:24 AM, Ben Rubinstein via use-livecode wrote:
As grepophile, I'd go for some variation on

While I heartily approve of Ben's use of grep, here's another approach using an array. Note that is somewhat specific to your data set, and from the looks of the data my guess is that you're heading down the path of csv madness.

on mouseUp pMouseBtnNo
   local tVar, tHeader, tCount, tOriginal

   put field 1 into tVar
   put line 1 of tVar into tHeader
   delete line 1 of tVar
   split tVar by cr

   repeat for each key tKey in tVar
      # transform "$8,303.32" into "$8303.32"
      repeat for each trueword tTrueWord in tVar[tKey]
         put tTrueWord into tOriginal
         replace comma with empty in tTrueWord
         replace tOriginal with tTrueWord in tVar[tKey]
      end repeat
      # now we can deal with commas as itemDelimiters
      put 1 into tCount
      repeat for each item tWord in tVar[tKey]
         put tWord into tVar[tKey][tCount]
         add 1 to tCount
      end repeat
   end repeat # for each key tKey in tVar

   # now pick out the desired total
   local tTotal, tOffset
   put itemoffset("Total", tHeader) into tOffset
   put tVar[5][tOffset] into tTotal
   breakpoint
end mouseUp

--
 Mark Wieder
 ahsoftw...@gmail.com

_______________________________________________
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