03-06-2024, 03:59 AM
This is the prog I use now to generate Random Access word-lists for my games.
Not very elegant, but effective. Maybe someone else will find it useful.
Thanks to bplus and others for help with RA.
Not very elegant, but effective. Maybe someone else will find it useful.
Thanks to bplus and others for help with RA.
Code: (Select All)
' RA Creator creates a Random Access file from the Collins Scrabble Dictionary, up to about 280000 words of 2 to 15 letters.
' Time taken should not exceed 10 seconds.
ScreenSetup:
Screen _NewImage(1120, 820, 32)
SetFont: f& = _LoadFont("C:\WINDOWS\fonts\courbd.ttf", 24, "monospace"): _Font f&
lhs = (_DesktopWidth - 1120) / 2
_ScreenMove lhs, 86 ' centre display on screen
Common Shared CPL, CTR
CPL = 1120 / _PrintWidth("X")
DefLng A ' 4 bytes allows for all word lengths
GEtANumber:
Input "Max Length (2 to 15)"; ML$ ' select a max word length for RA file
ML = Val(ML$)
Cls
If ML < 2 Or ML > 15 Or ML <> Int(ML) Then GoTo GEtANumber ' ML must be integer 2 - 15
FileName$ = "RA" + ML$: RecSize = ML + 4
Print "Creating RA file "; FileName$
Print
Open "words15.txt" For Input As #1 ' condensed dictionary with words up to 15 letters
Open FileName$ For Random As #2 Len = RecSize
While Not EOF(1)
Input #1, wd$
If Len(wd$) <= ML Then
a = a + 1: Put #2, a, wd$
End If
Wend
Print FileName$; " has"; a; "words, to"; ML; "letters max"
For b = 1 To 10
Get #2, b, wd$: Print wd$
Next
Print
Print "Last word is ";
Get #2, a, wd$: Print wd$
Close
Sleep: Clear: Run
Of all the places on Earth, and all the planets in the Universe, I'd rather live here (Perth, W.A.)
Please visit my Website at: http://oldendayskids.blogspot.com/
Please visit my Website at: http://oldendayskids.blogspot.com/