Sorting text

J. Landman Gay jacque at hyperactivesw.com
Wed Mar 7 13:23:10 EST 2007


Simon HARPER wrote:

> As an addition to this does the sorting machinery allow frequency counts 
> for words in a text field?

The old MetaCard IDE shipped with a very efficient word-counting script 
as one of its examples. Here it is with superfluous stuff removed and 
reformatted as a function:

function wordCount pText
   repeat for each word w in pText
     add 1 to wordCount[w]
   end repeat
   put keys(wordCount) into keyWords
   sort keyWords -- optional
   repeat for each line l in keyWords
     put l & tab & wordCount[l] & return after tResult
   end repeat
   return tResult
end wordCount

-- 
Jacqueline Landman Gay         |     jacque at hyperactivesw.com
HyperActive Software           |     http://www.hyperactivesw.com



More information about the use-livecode mailing list