johnno56, 1micha.elok could you test the sped of this version?
Thanx!
Code:
unwanted_characters = []
counter = 0
for a = 0 to 96
unwanted_characters[counter] = chr(a)
counter = counter + 1
next
for a = 123 to 127
unwanted_characters[counter] = chr(a)
counter = counter + 1
next
pln "Reading and processing the file..."
whole_text = lower(system("type Hamlet.txt"))
foreach y in unwanted_characters
whole_text = replace(whole_text, y, " ")
next
all_words = split(whole_text, " ")
pln "Counting..."
words_number = 0
unique_words = []
foreach n in all_words
if len(n) > 1 or n = "a" or n = "i"
unique_words[n] = unique_words[n] + 1
words_number = words_number + 1
endif
next
pln "Saving the result..."
create file 2, "Words.txt"
wln file 2, "All words - " + words_number
wln file 2, "Unique words - " + sizeof(unique_words)
wln file 2, ""
y = 1
while sizeof(unique_words)
foreach a, b in unique_words
if b = y then
wln file 2, a + " - " + b
endif
next
free val unique_words, y
y = y + 1
wend
free file 2
Thanx!