Word counter crashing LiveCode?

Alex Tweedly alex at tweedly.net
Sat Aug 25 07:01:19 EDT 2018


Not sure why yours is crashing, and I admit I haven't really looked 
closely :-)

I have a similar word count - so I tweaked it slightly :

  - stack with 3 fields - NoiseWords, Source and outputs results to "F"

  - button to make it run

*on*mouseUp*
    local*tSource, tNoise, tWord*s
**local*tANoise, tAWords
*put*thetextoffld"fSource"intotSource
*put*thetextoffld"fNoise"intotNoise*
    repeat* foreachwordW intNoise
*put*trueintotANoise[W]*
    end* *repeat*

*repeat* foreachwordW intSource*
        if* tANoise[W] *then* *next* *repeat**
       add*1totAWords[W]*
    end* *repeat*

*repeat* foreachkeyK intAWords*
       put*K && tAWords[K] &CRafterfld"F"*
   end* *repeat*

*end*mouseUp

Alex

On 25/08/2018 11:25, Keith Clarke via use-livecode wrote:
> 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
> _______________________________________________
> 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