This is a general programming issue but I would like to discuss what techniques/tricks to use when using BBC BASIC as language.
For example a program is needed to find all the unique 8-letter words from a text (txt) file as input and as output, list them alphabetically.
The text file size could be 10kb but also 10Gb. It could even be that a very big text file doesn't have any 8-letter words in it. Or the text file has 1000000 8-letter words in it.... which are all the same!
The start loop would be something like:
Code: Select all
DIM Wrd$(3000)
F%=OPENIN("Input.txt")
WHILE NOT EOF#F%
Word$=GET$#F%
IF LENWord$ == 8 THEN
Wrd$(N%)=Word$
N%+=1
ENDIF
ENDWHILE
CLOSE#F%
One technique I thought of for the start loop is writing a match to a new output text file first to avoid a wrong DIMmed array.
Another trick is to first scan de text file to count the total number of (non-unique) 8-letter words.
What would be a good approach and/or are there BBC BASIC example programs around doing something similar?
Thanks
Mike