如何使用LiveCode在数组中显示重复的单词

时间:2015-04-21 12:53:46

标签: livecode

我是LiveCode的初学者。我如何在数组中显示重复的单词及其计数。有可能吗?

global ar

on mouseUp
    --answer ar
    //ar contain some text
    put ar into s1
    split s1 by CR
    put the number of lines of (the keys of s1) into s2
    repeat for each word k in s1
        put  s1[k] into k1 
        split k1 by CR
    end repeat
    answer k1[1]
end mouseUp

repeat for each key j in myArrayT
    put  myArrayT[j] into k 
    split k by colon

1 个答案:

答案 0 :(得分:0)

制作一个字段并用一堆字填充,其中许多字重复一次或多次。将该字段命名为#34; wordList"。现在在按钮脚本中:

on mouseUp
   get fld "wordList"
  repeat for each word tWord in it
  add 1 to wordCount[tword]
 end repeat
 combine wordCount by return and comma
 answer wordCount
end mouseUp