Here's an easy fix for you to optimize your code and run it faster. (An increase of about 15x faster on my machine.)
I'll post 2 routines here so you can run them and compare for speed differences:
YOURS (modified to loop and run for a set amount of time -- 5 seconds in this case):
DIM SHARED ltr$
(9) '<<<<<<<<<<< shared to debug
'SET KEY AND LETTERS
in$ = "abcdefghi"
lenin
= LEN(in$
) '<<<<<<<<<<< for faster processing
'SPLIT UP LETTERS
ltr$
(n
) = MID$(in$
, n
, 1)
'LOAD ALL WORDS FROM .TXT FILE
OPEN "WordList.txt" FOR INPUT AS #1 '<<<<<<<<< moved to more appropriate place filecount = 0
filecount = filecount + 1
timelimit = 5
loopsran = loopsran + 1
'RUN THROUGH WORDS
templtr$
= MID$(word$
(n
), i
, 1) FOR x
= 1 TO lenin
'<<<<<<<<<<<<<<<<< main fix #1 ltr$(x) = ""
count = count + 1
'debugging
'PRINT "Update: file word = "; word$(n); " and here is current letters crossed off: "; letters$
'INPUT "OK press enter... "; wate$
FOR m
= 1 TO 9 'main fix #2 n's to m's ltr$
(m
) = MID$(in$
, m
, 1) count = 0
PRINT USING "###,###,###,###,### loops ran in ##.# seconds"; loopsran
, timelimit
'for debugging
b$ = b$ + ltr$(i)
letters$ = "*" + b$ + "*"
Modified:
DIM SHARED ltr
(9) '<<<<<<<<<<< shared to debug
'SET KEY AND LETTERS
in$ = "abcdefghi"
lenin
= LEN(in$
) '<<<<<<<<<<< for faster processing
'SPLIT UP LETTERS
'LOAD ALL WORDS FROM .TXT FILE
OPEN "WordList.txt" FOR BINARY AS #1 '<<<<<<<<< moved to more appropriate place filecount = 0
filecount = filecount + 1
timelimit = 5
loopsran = loopsran + 1
'RUN THROUGH WORDS
templtr
= ASC(word$
(n
), i
) FOR x
= 1 TO lenin
'<<<<<<<<<<<<<<<<< main fix #1 ltr(x) = 0
count = count + 1
skipmore:
FOR m
= 1 TO 9 'main fix #2 n's to m's count = 0
PRINT USING "###,###,###,###,### loops ran in ##.# seconds"; loopsran
, timelimit
'for debugging
b$ = b$ + ltr$(i)
letters$ = "*" + b$ + "*"
Yours will run 22 times in 5 seconds, mine 324 times...
The changes?
#1) STRINGS are gone. Why do we need them? Especially, WHY DO WE NEED MID$??
When going for speed routines, ASC outperforms MID$(x$,y,1) every time, hands down! This is a major performance boost.
#2) The word list is limited to begin with.
IF LEN(line$) < 10 THEN
filecount = filecount + 1
word$(filecount) = line$
END IF
You're not going to find 10 letter word matches with only 9 letter words.
#3) (Not timed, but a huge speed boost): Changed file from INPUT to BINARY and changed INPUT # to LINE INPUT#. This makes loading the word list a whole heck of a lot faster. Even faster would be to load it all at once and then parse the words out of it, but who wants to go through the trouble for all of the few microseconds we'd save in this case?
Simple little things, but the affect the performance like crazy.