[Gambas-user] Wordcount in a TextEdit

Ron Onstenk ronstk at ...239...
Fri Apr 18 17:39:55 CEST 2008


On Friday 18 April 2008 13:06, Maximillian Von Kloisterheim wrote:
> 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

Glad it did help but what solution? the basic style or the shell to wc command?

>You can tell Split() not to return void entries with its fourth optional argument.
>
>Regards,
>
>-- 
>Benoit Minisini

The fourth argument is new for me. Never to old to learn ;)

Greats to all

Ron




More information about the User mailing list