Word counter crashing LiveCode?

Keith Clarke keith.clarke at me.com
Sat Aug 25 06:25:29 EDT 2018


Folks,
I’m working on a simple utility to count the most popular words in a text file but my current code runs for a while & then causes LiveCode to crash.

It runs fine when I merely extract a list of unique words that are not in a ‘NoiseWords’ list but when I attempt to add a word count as the second item on the line it crashes after.

   repeat for each word tWord in tSource 
      
      # remove noisewords
      if tWord is among the lines of tNoiseWords then
         next repeat
      else
         
         #Process words 
         if tWord is among the lines of tWords then
            put lineOffset( tWord, tWords ) into tLine
            
            if offset(comma, line tLine of tWords) > 0 then
               add 1 to item 2 of line tLine of tWords
            else 
               put comma & 2 after line tLine of tWords
            end if
            
            next repeat
         else
            put tWord & comma & "1" & cr after tWords
         end if
         
      end if
      
   end repeat
 
I’m no developer so I may be using the wrong technique completely, so would welcome any steer.

Thanks in advance.
Keith


More information about the use-livecode mailing list