[Gambas-user] Wordcount in a TextEdit
Maximillian Von Kloisterheim
maximvonk at ...626...
Fri Apr 18 13:06:17 CEST 2008
Ron Onstenk wrote:
> sNoCR=string.replace(sTextin,"\r"," ") 'replace control character by spaces
> sNoLF=string.replace(sNoCR,"\l"," ")
> 'repeat for tabs ("\t") and any other you can enter
>
> asWords=split(sNoLF," ") 'split on spaces
> ' count(asWords) is dirty word count
> ' two or more spaces give also a entry on split but are empty
>
> count=0
> for i=0 to count(asWords) ' loop array for non space entries
> if trim( asWords[i] ) <> "" then count=count+1
> next
>
>
> or use the shell command 'wc' , see 'man wc'
>
> Ron
Thanks Ron, that did the trick a whole lot better than my efforts so far.
Regards
Max
More information about the User
mailing list