`word count
`latch
`april 18,2007
 
 
repeat
   input "Enter path and filename to count words in  : ";file$
   if file exist(file$)<>1
      print "File  <";upper$(file$);">  does not exist."
   endif
until file exist(file$)=1
 
print
Print "Counting..."
 
rem get file size
size=file size(file$)
dim filebyte(size)
count = 0
 
open to read 1,file$
   while file end(1)<>1
      read byte 1,char
      filebyte(count)=char
      inc count
   endwhile
close file 1
count=0
pos=0
 
while pos < size
   char1=filebyte(pos)
   if char1 > (32 and char1 < 127)
      char2 = filebyte(pos+1)
      if char2 = 32 or char2=13 or char2=9
         inc count
      endif
   endif
   inc pos
endwhile
 
 
print
print
print "There are ";count;" possible words in ";file$;"."