>hi-
>
>I was some help but what I need to do is I have a text file with different chapters going from chapter 1 to chapter 11 and I neeed to write some code that takes and tells a user how many for example times the word "and" appears in each chapter.
>
>thanks
>
>james
Well, I was assuming you wanted to list all words.
If the text might eventually contain than 65,000 lines, alines() is no good, since the array is limited to 65,000 elements. Therefore, I suggest you use LLFF instead. Just read one line at a time, and count how many times the word "and" appears. Something like this (untested code):
set library to foxtools
WordToFind = "and"
TextFile = "AllChapters.txt"
WordCount = 0
fHandle = fopen(TextFile)
if fHandle < 0
MessageBox("Can't open file.")
return
endif
do while not feof(fHandle)
line = fgets(fHandle)
for i = 1 to Words(line)
if upper(WordNum(line, i)) = upper(WordToFind)
WordCount = WordCount + 1
endif
next
enddo
fclose(fHandle)
? "Number of words:", WordCount
Difference in opinions hath cost many millions of lives: for instance, whether flesh be bread, or bread be flesh; whether whistling be a vice or a virtue; whether it be better to kiss a post, or throw it into the fire... (from Gulliver's Travels)