Parsing CSV File VIA Array? (Part II) - Found word(s) list error in the Text body

Bob Sneidar bobsneidar at iotecdigital.com
Sun Feb 9 14:59:29 EST 2014


Step through the repeat loop by putting a breakpoint in your handler just before the first repeat loop. Each time your handler changes an element in your array, inspect the array to ensure what you expected is what you got. There really is no other way to be certain you know what is in the array simply by following the lines of code. Not unless your brain uses fault intolerant persistent memory, which mine does not. 

also, it may be useful to use the form:

repeat for each line theLine in theData

Be careful using this form that you do not alter theData (by my example) as this will royally hose your results. 

Also, it may make it easier to read by putting an empty line before and after your control structures. It helps me anyway. 

on mouseUp
     put 1 into tTargetLine
   
     repeat for number of lines in cd fld "itemHold"
         get line tTargetLine of cd fld "itemHold"
      
        repeat with y = 1 to the number of items of it
              put item y of it into counterArray[item y of it][y]
        end repeat
      
      put the keys of counterArray into cd fld "Group2"
      
      -- my error is in here when I begin the subsequent loops i think as the array continues to add elements
      
      repeat with x = 1 to the number of lines in cd fld "group2"
           put line x of cd fld "group2" into tElement
         put 0 into tCounter
         
         repeat for each element thisElement in counterArray[tElement]
              put thisElement & return after cd fld "group3"
              add 1 to tCounter
         end repeat
         
         put "," & tCounter after line X of cd fld "group2"
         put "" into cd fld "group3"
      end repeat
      
      put return after cd fld "group2"
      add 1 to tTargetLine
   end repeat
end mouseUp

Bob
On Feb 8, 2014, at 21:12 , JOHN PATTEN <johnpatten at me.com> wrote:

> (Part II of MSG)
> Here’s the script I’m using:
> 
> on mouseUp
>   put 1 into tTargetLine
>   repeat for number of lines in cd fld "itemHold"
>    get line tTargetLine of cd fld "itemHold"
>   repeat with y = 1 to the number of items of it
>      put item y of it into counterArray[item y of it][y]
>   end repeat
> put the keys of counterArray into cd fld "Group2"
> 
> -- my error is in here when I begin the subsequent loops i think as the array continues to add elements
> 
> repeat with x = 1 to the number of lines in cd fld "group2"
>   put line x of cd fld "group2" into tElement
> put 0 into tCounter
> repeat for each element thisElement in counterArray[tElement]
>   put thisElement & return after cd fld "group3"
>   add 1 to tCounter
> end repeat
> put "," & tCounter after line X of cd fld "group2"
> put "" into cd fld "group3"
> end repeat
> put return after cd fld "group2"
> add 1 to tTargetLine
> end repeat
> end mouseUp
> 
> I’m afraid I’m making this more complicated than it has to be. Any suggestions?
> 
> Thank you!
> _______________________________________________
> use-livecode mailing list
> use-livecode at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode





More information about the use-livecode mailing list