Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
More info about Random Access files
#15
(02-24-2026, 06:06 AM)PhilOfPerth Wrote: Thanks all; I now have a prog that generates R/A files of words of any length (up to 15 letters). 
May be useful to other word-game freaks)!

Code: (Select All)
SW = 1040: SH = 720
Screen _NewImage(SW, SH, 32)
SetFont: F& = _LoadFont("C:\WINDOWS\fonts\courbd.ttf", 20, "monospace"): _Font F&
_ScreenMove (_DesktopWidth - SW) / 2, 90

'get longest data length                                    10, length of FLASHPOINT
Input "Max Data length"; MaxLength
RL = MaxLength + 2 '                                        Len needs to be extended by 2 bytes
RandFile$ = "RandTo" + LTrim$(Str$(MaxLength))
RecNum = 0

Open "SerialWords.txt" For Input As #1
Open RandFile$ For Random As #2 Len = RL 'prepare R/A file

' Read each word and write to random file
While Not EOF(1)
   Input #1, wrd$
   If Len(wrd$) <= MaxLength Then

      ' only put words up to length requested
      RecNum = RecNum + 1
      Put #2, RecNum, wrd$
   End If
Wend
Close
Print "Created "; RandFile$; " with "; RecNum; " records": Sleep 2
Cls

' Verify the random access file
Print: Print "Reading sample from random access file:"
Open RandFile$ For Random As #1 Len = MaxLength + 2
For a = 1 To 20
   Get #1, a, wrd$: Print wrd$; "  ";
Next
Close
End
Sleep
The word- file attached is the "cleaned-up" Collins dictionary
       This is pretty cool, but it has given me another idea.   It would be possible to leave the original Word file as Plain text with any length words and build an Index file for it
with long (or even _INTEGER64 but long is probably fine !) values that represent the File Positions of each word in the Text file !    It would save space on VERY large word files.

   The file would only have to be indexed once if static or otherwise it would need to be reindexed each time it was changed !
Reply


Messages In This Thread
RE: More info about Random Access files - by Pete - 02-24-2026, 01:44 AM
RE: More info about Random Access files - by Pete - 02-24-2026, 05:13 AM
RE: More info about Random Access files - by ahenry3068 - 02-24-2026, 06:58 AM
RE: More info about Random Access files - by Jack - 02-24-2026, 02:41 PM
RE: More info about Random Access files - by Pete - 02-24-2026, 05:28 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Embedding and Extracting MANY files ! ahenry3068 20 1,541 11-15-2025, 10:19 AM
Last Post: ahenry3068
  random maze map. math help pmackay 4 564 08-10-2025, 11:22 AM
Last Post: pmackay
  Random Number Generator pmackay 14 1,266 07-30-2025, 12:56 PM
Last Post: SMcNeill
  generating a random number in the full range of that number? (Integer, Long) madscijr 2 657 05-01-2025, 09:11 PM
Last Post: madscijr
  program that stitches together a bunch of image files into one giant poster? madscijr 15 2,340 10-24-2024, 06:08 PM
Last Post: madscijr

Forum Jump:


Users browsing this thread: 1 Guest(s)