[futurebasic] Re: [FB] word count routine

Message: < previous - next > : Reply : Subscribe : Cleanse
Home   : September 2001 : Group Archive : Group : All Groups

From: Jay Reeve <jktr@...>
Date: Fri, 21 Sep 01 10:05:29 -0500
>a word count basically counts spaces and returns.
>this doesn't take false possitives from double spaces and multiple returns.
>
>enjoy,
>:-j
>
Here's my version. Enjoy.

 0"0
 =J= a  y
  "

'----------- start code -----------
local mode
clear local fn wordCount( theContH as handle)
dim myCount     as unsigned long
dim myOffset    as unsigned long
dim prev        as byte
dim myType(255) as boolean
xref@ myText(_maxLong) as char
'Specify delimiters here
myType( 13 ) = 1
myType(_" ") = 1
'
myText   = theContH
myOffset = fn gethandlesize( theContH)
prev     = 1
while myOffset
myOffset --
long if myType( myText( myOffset ) ) <> prev
if prev then myCount ++
prev = 1 - prev
end if
wend
end fn = myCount
'--------------- end code ---------------