Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
More info about Random Access files
#11
Yes, when you use LEN with OPEN for RANDOM, the LEN is the length of the records.

But when using variable length strings, the max length of a string that you can use is that LEN - 2, as it also stores the size in front of it.

a$ = "Test"

When a$, which is a variable length string is stored, it's stored as 2-bytes for INTEGER size and then 4 bytes for the string.  Everything after that is basically just ignored.

a$(4) = "Test"

Now a$(4) is a fixed-length string of 4-bytes.  When you put it to file, it puts those 4 bytes to the file with no size in front of it.

Variable length strings have a total length limit reduced in total size by 2 bytes as they store the size with the string data.  Fixed length strings just store the data.  That's the difference you're seeing here.

So when you do something like:

OPEN "foo.txt" FOR RANDOM AS #1 LEN = 15
a$ = "123456789012345"
PUT #1, , a$

You'll get an error as what it wants to PUT is 2-bytes for length + 15 bytes for the variable length string, which is MORE than the 15 byte record size.  This is what Phil was seeing in his original post.

It's two different behaviors for two different types of data.

Variable length strings -- it puts a 2-byte integer for the size of the string, and then the string.
Fixed length strings -- it just puts the fixed length string directly to the file.

That's the difference in a nutshell.

The record size is *always* the size you specify.  But variable length strings are going to have a 2-byte size integer attached to the front of them when writing them, so the end result is they're limited to 2-bytes LESS than the total record size.

The reason for this difference?

It's so when you read back a variable length string, it doesn't automagically add all those blank spaces to the end of the string.

OPEN "crap" FOR RANDOM AS #1 LEN = 10
a$ = "1234"
a$(10) = "1234"
PUT #1, , a$
PUT #1, , 1$(10)
GET #1, 1, a$
GET #1, , a$(10)

The difference in the above is when we PRINT those two strings, they're going to look quite different.

a$ will print "1234"
a$(10) will print "1234------", which is the 1234 with 6 spaces after it.

a$ won't have those spaces; a$(10) will.   But the way to preserve the EXACT size with variable length strings *requires* you to save the size first, and that's 2-bytes.  So when you write the variable length string, it's 2-bytes for size + the data itself, which means the overall data size has to be 2 less than your total record length or you get an error.
Reply
#12
@ Pete 
Quote: You can get away with strings of different lengths, but the longest string cannot exceed the specified file length, minus 2-bytes.
Yes, that's exactly what I've found, just didn't know why. Thanks.
Of all the places on Earth, and all the planets in the Universe, I'd rather live here (Perth, Western Australia.) Big Grin
Please visit my Website at: http://oldendayskids.blogspot.com/
Reply
#13
Of course if you do want to get the length of the text to match the length of the file...

Code: (Select All)
Open "crap" For Output As #1: Close #1
Dim q As String * 10
q = "123"
Open "crap" For Random As #1 Len = 10
Put #1, , q
Close #1
q = ""
Open "crap" For Random As #1 Len = 10
Get #1, , q
Close #1
Print "|" + q + "|"
End

Note that q is displayed as 123 but it's really a 10-character string. You can use _Trim$() to remove those Chr$(32) spaces.

Pete
Reply
#14
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


Attached Files
.7z   SerialWords.7z (Size: 570.31 KB / Downloads: 4)
Of all the places on Earth, and all the planets in the Universe, I'd rather live here (Perth, Western Australia.) Big Grin
Please visit my Website at: http://oldendayskids.blogspot.com/
Reply
#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
#16
I decided to implement my suggestion.  Just some quick dirty code with a Downloaded words.txt with 466550 words.

   Some of these words are a bit ridiculous IMHO.   But it was an extreme case for my Indexing algorithm and It seems to
Work fine.

Words can be ANY length. Just need to be terminated with a CR and/or LF. When the index File is built
it stores the beginning position of each word. This only needs to be DONE once (or if the words file is changed !)

   This code could use a bit of refining but IT WORKS !
As is it ASSUMES words.txt has at least 1 word already (will goof up otherwise !)
IT SHOULD (but does not) check if words.txt has been changed since last indexing and reindex if it has changed !

WordFromFile doesn't do bounds checking, This should be fixed for production code !

(Probably wouldn't have thought of this except for messing around so much with DBASE in the 90's !) 

Code: (Select All)
Option _Explicit

CheckIndex

Print
Print Wordfromfile(10)
Print Wordfromfile(100)
Print Wordfromfile(22222)
Print Wordfromfile(100001)

End



Function Wordfromfile$ (WordIndex As _Unsigned Long)
    Dim TMP$
    Dim C As String * 1
    Dim WordPos As _Unsigned Long

    Open "words.txt.index" For Random As #1 Len = 4
    Get #1, WordIndex, WordPos
    Close #1
    Open "words.txt" For Binary As #1
    Seek #1, WordPos
    Get #1, , C
    Do
        TMP$ = TMP$ + C
        Get #1, , C
    Loop Until C = Chr$(10) Or C = Chr$(13)
    Close 1
    Wordfromfile = TMP$
End Function


Sub CheckIndex
    If Not _FileExists("words.txt") Then
        Print
        Print "words.txt not found !"
        Print
        Print
        End
    End If
    If Not _FileExists("words.txt.index") Then
        BuildWordIndex
    End If
End Sub


Sub BuildWordIndex
    Dim WordCount As _Unsigned Long
    Dim WordPos As _Unsigned Long
    Dim BufferIndex As _Unsigned Long
    Dim DONE As Integer
    Dim LastCharacter As Long
    Dim GOT_A_LINE As Integer

    Print
    Print "Building Word Index"
    Open "words.txt" For Binary As #1
    LastCharacter = LOF(1) - 1
    Dim BUFFER(0 To LastCharacter) As _Unsigned _Byte
    Get 1, , BUFFER()

    Open "words.txt.index" For Binary As #2
    BufferIndex = 0
    Do
        WordCount = WordCount + 1
        Locate 4, 4
        Print "INDEXING WORD#:"; WordCount
        WordPos = BufferIndex + 1
        Put #2, , WordPos
        GOT_A_LINE = _FALSE
        Do
            DONE = _FALSE
            Select Case BUFFER(BufferIndex)
                Case 32 To 127
                    If GOT_A_LINE Then
                        DONE = _TRUE
                    Else
                        BufferIndex = BufferIndex + 1
                    End If
                Case 13, 10
                    GOT_A_LINE = _TRUE
                    BufferIndex = BufferIndex + 1
                Case Else
                    BufferIndex = BufferIndex + 1
            End Select
            If BufferIndex > LastCharacter Then Exit Do
        Loop Until DONE
    Loop Until BufferIndex >= LastCharacter
    Close 1
    Close 2
End Sub


Attached Files
.txt   words.txt (Size: 4.64 MB / Downloads: 6)
.bas   WORDINDEX.BAS (Size: 2.12 KB / Downloads: 2)
Reply
#17
@SMcneill OK I didn't know you could do a Random Access without LEN in Open statement, was that in QB4.5?

@ahenry3068 dont see advantage of an index file, you still need to do a binary search to find the word fast, might as well do it with the original word file.

@PhilOfPerth didnt we do Random Access with Alchemy years ago! with a Binary word search off the Collins Dictionary.
  724  855  599  923  575  468  400  206  147  564  878  823  652  556 bxor cross forever
Reply
#18
(02-24-2026, 12:49 PM)bplus Wrote: @SMcneill OK I didn't know you could do a Random Access without LEN in Open statement, was that in QB4.5?

@ahenry3068 dont see advantage of an index file, you still need to do a binary search to find the word fast, might as well do it with the original word file.

@PhilOfPerth didnt we do Random Access with Alchemy years ago! with a Binary word search off the Collins Dictionary.


       The optimum approach will always vary for different applications.   In this particular case Phil's approach caps the string length at 15 characters.  The indexed
approach allows any length of word !  (or other string,  I threw this code together, and could have done other stuff to filter a single word, but I just wanted to illustrate the approach)

        Probably not such a big advantage on modern systems, but on older slower stuff going through a smaller index file to find a record was almost
always faster than searching the larger file !

       Anyway just want to illustrate what can be a useful approach in some cases !
Reply
#19
on  October 08, 2021 I posted a translation of the blowfish encryption program on the now defunct forum
Quote: in my test when decrypting a text file all is good except that there are a few garbage characters at the end of the file, perhaps you may want to fix that, or no
maybe it's related to this issue, I re-post the code here, some corrections may be needed since the changes to QB64pe involving the underscore
Code: (Select All)

    $Console:Only
    _Dest _Console
   
    Option _Explicit
   
    Const MAXKEYBYTES = 56
    Const N = 16
    Const low_bound = 3
    Const high_bound = 255
    Const num_elements_size = (low_bound + 1) * (high_bound + 1) * 4
    Const array_offset = 4 * high_bound ' 4 is the size of a ulong
   
    Type blowfish_ctx
        p As String * 72 ' (n + 2) * 4 or p(0 to n+1)
        s As String * Num_elements_size ' array(3, 255) of ulong
    End Type
   
    Dim Shared orig_p(0 To (16 + 2) - 1) As _Unsigned Long
    Dim Shared orig_s(0 To 3, 0 To 255) As _Unsigned Long
   
    Call initialize
   
    Dim As blowfish_ctx ctx
    Dim As _Unsigned Long l, r
    l = 1
    r = 2
    Call blowfish_init(ctx, "TESTKEY", 7)
    Call blowfish_encrypt(ctx, l, r)
    Print Hex$(l)
    Print Hex$(r)
    Call Blowfish_Decrypt(ctx, l, r)
    Print l
    Print r
    Dim As String passwd
    passwd = "TESTKEY"
    Call blowfish_init(ctx, passwd, Len(passwd))
    Open "test.txt" For Binary As #1
    Open "test_enc.txt" For Binary As #2
   
    While Not EOF(1)
        Get #1, , l
        Get #1, , r
        Call blowfish_encrypt(ctx, l, r)
        Put #2, , l
        Put #2, , r
    Wend
    Close 1, 2
    'passwd = "TESTKEY"
    'call Blowfish_Init(ctx, passwd, Len(passwd))
    Open "test_enc.txt" For Binary As #1
    Open "test_dec.txt" For Binary As #2
   
    While Not EOF(1)
        Get #1, , l
        Get #1, , r
        Call Blowfish_Decrypt(ctx, l, r)
        Put #2, , l
        Put #2, , r
    Wend
    Close 1, 2
   
    Sub initialize
        Dim ct As Integer
        For ct = 0 To 17
            Read orig_p(ct)
        Next ct
        For ct = 0 To 255
            Read orig_s(0, ct)
        Next ct
        For ct = 0 To 255
            Read orig_s(1, ct)
        Next ct
        For ct = 0 To 255
            Read orig_s(2, ct)
        Next ct
        For ct = 0 To 255
            Read orig_s(3, ct)
        Next ct
    End Sub
   
    Function idx1& (i&)
        idx1 = 4 * i& + 1
    End Function
   
    Function idx2& (i&, j&)
        idx2 = array_offset * i& + 4 * i& + 4 * j& + 1
    End Function
   
    Sub set1 (s$, i&, v~&)
        Mid$(s$, 4 * i& + 1, 4) = MKL$(v~&)
    End Sub
   
    Function get1~& (s$, i&)
        get1 = CVL(Mid$(s$, 4 * i& + 1, 4))
    End Function
   
    Sub set2 (s$, i&, j&, v~&)
        Mid$(s$, array_offset * i& + 4 * i& + 4 * j& + 1, 4) = MKL$(v~&)
    End Sub
   
    Function get2~& (s$, i&, j&)
        get2 = CVL(Mid$(s$, array_offset * i& + 4 * i& + 4 * j& + 1, 4))
    End Function
   
    Function f~& (ctx As blowfish_ctx, x1 As _Unsigned Long)
        Dim As _Unsigned Integer a, b, c, d
        Dim As _Unsigned Long x, y
        x = x1
        d = x And &H00FF
        x = _SHR(x, 8)
        c = x And &H00FF
        x = _SHR(x, 8)
        b = x And &H00FF
        x = _SHR(x, 8)
        a = x And &H00FF
        y = get2(ctx.s, 0, a) + get2(ctx.s, 1, b)
        y = y Xor get2(ctx.s, 2, c)
        y = y + get2(ctx.s, 3, d)
        f = y
    End Function
   
    Sub blowfish_encrypt (ctx As blowfish_ctx, xl As _Unsigned Long, xr As _Unsigned Long)
        Dim As _Unsigned Long x_l, x_r, temp
        Dim i As Long
        x_l = xl
        x_r = xr
   
        For i = 0 To N - 1
            x_l = x_l Xor get1(ctx.p, i)
            x_r = f(ctx, x_l) Xor x_r
            temp = x_l
            x_l = x_r
            x_r = temp
        Next
        temp = x_l
        x_l = x_r
        x_r = temp
        x_r = x_r Xor get1(ctx.p, 16)
        x_l = x_l Xor get1(ctx.p, (16 + 1))
        xl = x_l
        xr = x_r
    End Sub
   
    Sub Blowfish_Decrypt (ctx As blowfish_ctx, xl As _Unsigned Long, xr As _Unsigned Long)
        Dim As _Unsigned Long X_l, X_r, temp
        Dim i As Long
        X_l = xl
        X_r = xr
        For i = N + 1 To 2 Step -1
            X_l = X_l Xor get1(ctx.p, i)
            X_r = f(ctx, X_l) Xor X_r
            temp = X_l
            X_l = X_r
            X_r = temp
        Next
        temp = X_l
        X_l = X_r
        X_r = temp
        X_r = X_r Xor get1(ctx.p, 1)
        X_l = X_l Xor get1(ctx.p, 0)
        xl = X_l
        xr = X_r
    End Sub
   
    Sub blowfish_init (ctx As blowfish_ctx, pass_key As String, keylen As Long)
        Dim As Long i, j, k
        Dim As _Unsigned Long data2, datal, datar
        For i = 0 To 3
            For j = 0 To 255
                Call set2(ctx.s, i, j, orig_s(i, j))
            Next
        Next
        j = 0
        For i = 0 To N + 1
            data2 = 0
            For k = 0 To 3
                data2 = _SHL(data2, 8) Or Asc(pass_key, j + 1)
                j = j + 1
                If j >= keylen Then
                    j = 0
                End If
            Next
            Call set1(ctx.p, i, orig_p(i) Xor data2)
        Next
        datal = 0
        datar = 0
        For i = 0 To N + 1 Step 2
            Call blowfish_encrypt(ctx, datal, datar)
            Call set1(ctx.p, i, datal)
            Call set1(ctx.p, i + 1, datar)
        Next
        For i = 0 To 3
            For j = 0 To 255 Step 2
                Call blowfish_encrypt(ctx, datal, datar)
                Call set2(ctx.s, i, j, datal)
                Call set2(ctx.s, i, j + 1, datar)
            Next
        Next
    End Sub
   
    Data &H243F6A88,&H85A308D3,&H13198A2E,&H3707344
    Data &HA4093822,&H299F31D0,&H82EFA98,&HEC4E6C89
    Data &H452821E6,&H38D01377,&HBE5466CF,&H34E90C6C
    Data &HC0AC29B7,&HC97C50DD,&H3F84D5B5,&HB5470917
    Data &H9216D5D9,&H8979FB1B
   
    Data &HD1310BA6,&H98DFB5AC,&H2FFD72DB,&HD01ADFB7
    Data &HB8E1AFED,&H6A267E96,&HBA7C9045,&HF12C7F99
    Data &H24A19947,&HB3916CF7,&H801F2E2,&H858EFC16
    Data &H636920D8,&H71574E69,&HA458FEA3,&HF4933D7E
    Data &HD95748F,&H728EB658,&H718BCD58,&H82154AEE
    Data &H7B54A41D,&HC25A59B5,&H9C30D539,&H2AF26013
    Data &HC5D1B023,&H286085F0,&HCA417918,&HB8DB38EF
    Data &H8E79DCB0,&H603A180E,&H6C9E0E8B,&HB01E8A3E
    Data &HD71577C1,&HBD314B27,&H78AF2FDA,&H55605C60
    Data &HE65525F3,&HAA55AB94,&H57489862,&H63E81440
    Data &H55CA396A,&H2AAB10B6,&HB4CC5C34,&H1141E8CE
    Data &HA15486AF,&H7C72E993,&HB3EE1411,&H636FBC2A
    Data &H2BA9C55D,&H741831F6,&HCE5C3E16,&H9B87931E
    Data &HAFD6BA33,&H6C24CF5C,&H7A325381,&H28958677
    Data &H3B8F4898,&H6B4BB9AF,&HC4BFE81B,&H66282193
    Data &H61D809CC,&HFB21A991,&H487CAC60,&H5DEC8032
   
    Data &HEF845D5D,&HE98575B1,&HDC262302,&HEB651B88
    Data &H23893E81,&HD396ACC5,&HF6D6FF3,&H83F44239
    Data &H2E0B4482,&HA4842004,&H69C8F04A,&H9E1F9B5E
    Data &H21C66842,&HF6E96C9A,&H670C9C61,&HABD388F0
    Data &H6A51A0D2,&HD8542F68,&H960FA728,&HAB5133A3
    Data &H6EEF0B6C,&H137A3BE4,&HBA3BF050,&H7EFB2A98
    Data &HA1F1651D,&H39AF0176,&H66CA593E,&H82430E88
    Data &H8CEE8619,&H456F9FB4,&H7D84A5C3,&H3B8B5EBE
    Data &HE06F75D8,&H85C12073,&H401A449F,&H56C16AA6
    Data &H4ED3AA62,&H363F7706,&H1BFEDF72,&H429B023D
    Data &H37D0D724,&HD00A1248,&HDB0FEAD3,&H49F1C09B
    Data &H75372C9,&H80991B7B,&H25D479D8,&HF6E8DEF7
    Data &HE3FE501A,&HB6794C3B,&H976CE0BD,&H4C006BA
    Data &HC1A94FB6,&H409F60C4,&H5E5C9EC2,&H196A2463
    Data &H68FB6FAF,&H3E6C53B5,&H1339B2EB,&H3B52EC6F
    Data &H6DFC511F,&H9B30952C,&HCC814544,&HAF5EBD09
   
    Data &HBEE3D004,&HDE334AFD,&H660F2807,&H192E4BB3
    Data &HC0CBA857,&H45C8740F,&HD20B5F39,&HB9D3FBDB
    Data &H5579C0BD,&H1A60320A,&HD6A100C6,&H402C7279
    Data &H679F25FE,&HFB1FA3CC,&H8EA5E9F8,&HDB3222F8
    Data &H3C7516DF,&HFD616B15,&H2F501EC8,&HAD0552AB
    Data &H323DB5FA,&HFD238760,&H53317B48,&H3E00DF82
    Data &H9E5C57BB,&HCA6F8CA0,&H1A87562E,&HDF1769DB
    Data &HD542A8F6,&H287EFFC3,&HAC6732C6,&H8C4F5573
    Data &H695B27B0,&HBBCA58C8,&HE1FFA35D,&HB8F011A0
    Data &H10FA3D98,&HFD2183B8,&H4AFCB56C,&H2DD1D35B
    Data &H9A53E479,&HB6F84565,&HD28E49BC,&H4BFB9790
    Data &HE1DDF2DA,&HA4CB7E33,&H62FB1341,&HCEE4C6E8
    Data &HEF20CADA,&H36774C01,&HD07E9EFE,&H2BF11FB4
    Data &H95DBDA4D,&HAE909198,&HEAAD8E71,&H6B93D5A0
    Data &HD08ED1D0,&HAFC725E0,&H8E3C5B2F,&H8E7594B7
    Data &H8FF6E2FB,&HF2122B64,&H8888B812,&H900DF01C
   
    Data &H4FAD5EA0,&H688FC31C,&HD1CFF191,&HB3A8C1AD
    Data &H2F2F2218,&HBE0E1777,&HEA752DFE,&H8B021FA1
    Data &HE5A0CC0F,&HB56F74E8,&H18ACF3D6,&HCE89E299
    Data &HB4A84FE0,&HFD13E0B7,&H7CC43B81,&HD2ADA8D9
    Data &H165FA266,&H80957705,&H93CC7314,&H211A1477
    Data &HE6AD2065,&H77B5FA86,&HC75442F5,&HFB9D35CF
    Data &HEBCDAF0C,&H7B3E89A0,&HD6411BD3,&HAE1E7E49
    Data &H250E2D,&H2071B35E,&H226800BB,&H57B8E0AF
    Data &H2464369B,&HF009B91E,&H5563911D,&H59DFA6AA
    Data &H78C14389,&HD95A537F,&H207D5BA2,&H2E5B9C5
    Data &H83260376,&H6295CFA9,&H11C81968,&H4E734A41
    Data &HB3472DCA,&H7B14A94A,&H1B510052,&H9A532915
    Data &HD60F573F,&HBC9BC6E4,&H2B60A476,&H81E67400
    Data &H8BA6FB5,&H571BE91F,&HF296EC6B,&H2A0DD915
    Data &HB6636521,&HE7B9F9B6,&HFF34052E,&HC5855664
    Data &H53B02D5D,&HA99F8FA1,&H8BA4799,&H6E85076A
   
    Data &H4B7A70E9,&HB5B32944,&HDB75092E,&HC4192623
    Data &HAD6EA6B0,&H49A7DF7D,&H9CEE60B8,&H8FEDB266
    Data &HECAA8C71,&H699A17FF,&H5664526C,&HC2B19EE1
    Data &H193602A5,&H75094C29,&HA0591340,&HE4183A3E
    Data &H3F54989A,&H5B429D65,&H6B8FE4D6,&H99F73FD6
    Data &HA1D29C07,&HEFE830F5,&H4D2D38E6,&HF0255DC1
    Data &H4CDD2086,&H8470EB26,&H6382E9C6,&H21ECC5E
    Data &H9686B3F,&H3EBAEFC9,&H3C971814,&H6B6A70A1
    Data &H687F3584,&H52A0E286,&HB79C5305,&HAA500737
    Data &H3E07841C,&H7FDEAE5C,&H8E7D44EC,&H5716F2B8
    Data &HB03ADA37,&HF0500C0D,&HF01C1F04,&H200B3FF
    Data &HAE0CF51A,&H3CB574B2,&H25837A58,&HDC0921BD
    Data &HD19113F9,&H7CA92FF6,&H94324773,&H22F54701
    Data &H3AE5E581,&H37C2DADC,&HC8B57634,&H9AF3DDA7
    Data &HA9446146,&HFD0030E,&HECC8C73E,&HA4751E41
    Data &HE238CD99,&H3BEA0E2F,&H3280BBA1,&H183EB331
   
    Data &H4E548B38,&H4F6DB908,&H6F420D03,&HF60A04BF
    Data &H2CB81290,&H24977C79,&H5679B072,&HBCAF89AF
    Data &HDE9A771F,&HD9930810,&HB38BAE12,&HDCCF3F2E
    Data &H5512721F,&H2E6B7124,&H501ADDE6,&H9F84CD87
    Data &H7A584718,&H7408DA17,&HBC9F9ABC,&HE94B7D8C
    Data &HEC7AEC3A,&HDB851DFA,&H63094366,&HC464C3D2
    Data &HEF1C1847,&H3215D908,&HDD433B37,&H24C2BA16
    Data &H12A14D43,&H2A65C451,&H50940002,&H133AE4DD
    Data &H71DFF89E,&H10314E55,&H81AC77D6,&H5F11199B
    Data &H43556F1,&HD7A3C76B,&H3C11183B,&H5924A509
    Data &HF28FE6ED,&H97F1FBFA,&H9EBABF2C,&H1E153C6E
    Data &H86E34570,&HEAE96FB1,&H860E5E0A,&H5A3E2AB3
    Data &H771FE71C,&H4E3D06FA,&H2965DCB9,&H99E71D0F
    Data &H803E89D6,&H5266C825,&H2E4CC978,&H9C10B36A
    Data &HC6150EBA,&H94E2EA78,&HA5FC3C53,&H1E0A2DF4
    Data &HF2F74EA7,&H361D2B3D,&H1939260F,&H19C27960
   
    Data &H5223A708,&HF71312B6,&HEBADFE6E,&HEAC31F66
    Data &HE3BC4595,&HA67BC883,&HB17F37D1,&H18CFF28
    Data &HC332DDEF,&HBE6C5AA5,&H65582185,&H68AB9802
    Data &HEECEA50F,&HDB2F953B,&H2AEF7DAD,&H5B6E2F84
    Data &H1521B628,&H29076170,&HECDD4775,&H619F1510
    Data &H13CCA830,&HEB61BD96,&H334FE1E,&HAA0363CF
    Data &HB5735C90,&H4C70A239,&HD59E9E0B,&HCBAADE14
    Data &HEECC86BC,&H60622CA7,&H9CAB5CAB,&HB2F3846E
    Data &H648B1EAF,&H19BDF0CA,&HA02369B9,&H655ABB50
    Data &H40685A32,&H3C2AB4B3,&H319EE9D5,&HC021B8F7
    Data &H9B540B19,&H875FA099,&H95F7997E,&H623D7DA8
    Data &HF837889A,&H97E32D77,&H11ED935F,&H16681281
    Data &HE358829,&HC7E61FD6,&H96DEDFA1,&H7858BA99
    Data &H57F584A5,&H1B227263,&H9B83C3FF,&H1AC24696
    Data &HCDB30AEB,&H532E3054,&H8FD948E4,&H6DBC3128
    Data &H58EBF2EF,&H34C6FFEA,&HFE28ED61,&HEE7C3C73
   
    Data &H5D4A14D9,&HE864B7E3,&H42105D14,&H203E13E0
    Data &H45EEE2B6,&HA3AAABEA,&HDB6C4F15,&HFACB4FD0
    Data &HC742F442,&HEF6ABBB5,&H654F3B1D,&H41CD2105
    Data &HD81E799E,&H86854DC7,&HE44B476A,&H3D816250
    Data &HCF62A1F2,&H5B8D2646,&HFC8883A0,&HC1C7B6A3
    Data &H7F1524C3,&H69CB7492,&H47848A0B,&H5692B285
    Data &H95BBF00,&HAD19489D,&H1462B174,&H23820E00
    Data &H58428D2A,&HC55F5EA,&H1DADF43E,&H233F7061
    Data &H3372F092,&H8D937E41,&HD65FECF1,&H6C223BDB
    Data &H7CDE3759,&HCBEE7460,&H4085F2A7,&HCE77326E
    Data &HA6078084,&H19F8509E,&HE8EFD855,&H61D99735
    Data &HA969A7AA,&HC50C06C2,&H5A04ABFC,&H800BCADC
    Data &H9E447A2E,&HC3453484,&HFDD56705,&HE1E9EC9
    Data &HDB73DBD3,&H105588CD,&H675FDA79,&HE3674340
    Data &HC5C43465,&H713E38D8,&H3D28F89E,&HF16DFF20
    Data &H153E21E7,&H8FB03D4A,&HE6E39F2B,&HDB83ADF7
   
    Data &HE93D5A68,&H948140F7,&HF64C261C,&H94692934
    Data &H411520F7,&H7602D4F7,&HBCF46B2E,&HD4A20068
    Data &HD4082471,&H3320F46A,&H43B7D4B7,&H500061AF
    Data &H1E39F62E,&H97244546,&H14214F74,&HBF8B8840
    Data &H4D95FC1D,&H96B591AF,&H70F4DDD3,&H66A02F45
    Data &HBFBC09EC,&H3BD9785,&H7FAC6DD0,&H31CB8504
    Data &H96EB27B3,&H55FD3941,&HDA2547E6,&HABCA0A9A
    Data &H28507825,&H530429F4,&HA2C86DA,&HE9B66DFB
    Data &H68DC1462,&HD7486900,&H680EC0A4,&H27A18DEE
    Data &H4F3FFEA2,&HE887AD8C,&HB58CE006,&H7AF4D6B6
    Data &HAACE1E7C,&HD3375FEC,&HCE78A399,&H406B2A42
    Data &H20FE9E35,&HD9F385B9,&HEE39D7AB,&H3B124E8B
    Data &H1DC9FAF7,&H4B6D1856,&H26A36631,&HEAE397B2
    Data &H3A6EFA74,&HDD5B4332,&H6841E7F7,&HCA7820FB
    Data &HFB0AF54E,&HD8FEB397,&H454056AC,&HBA489527
    Data &H55533A3A,&H20838D87,&HFE6BA9B7,&HD096954B
   
    Data &H55A867BC,&HA1159A58,&HCCA92963,&H99E1DB33
    Data &HA62A4A56,&H3F3125F9,&H5EF47E1C,&H9029317C
    Data &HFDF8E802,&H4272F70,&H80BB155C,&H5282CE3
    Data &H95C11548,&HE4C66D22,&H48C1133F,&HC70F86DC
    Data &H7F9C9EE,&H41041F0F,&H404779A4,&H5D886E17
    Data &H325F51EB,&HD59BC0D1,&HF2BCC18F,&H41113564
    Data &H257B7834,&H602A9C60,&HDFF8E8A3,&H1F636C1B
    Data &HE12B4C2,&H2E1329E,&HAF664FD1,&HCAD18115
    Data &H6B2395E0,&H333E92E1,&H3B240B62,&HEEBEB922
    Data &H85B2A20E,&HE6BA0D99,&HDE720C8C,&H2DA2F728
    Data &HD0127845,&H95B794FD,&H647D0862,&HE7CCF5F0
    Data &H5449A36F,&H877D48FA,&HC39DFD27,&HF33E8D1E
    Data &HA476341,&H992EFF74,&H3A6F6EAB,&HF4F8FD37
    Data &HA812DC60,&HA1EBDDF8,&H991BE14C,&HDB6E6B0D
    Data &HC67B5510,&H6D672C37,&H2765D43B,&HDCD0E804
    Data &HF1290DC7,&HCC00FFA3,&HB5390F92,&H690FED0B
   
    Data &H667B9FFB,&HCEDB7D9C,&HA091CF0B,&HD9155EA3
    Data &HBB132F88,&H515BAD24,&H7B9479BF,&H763BD6EB
    Data &H37392EB3,&HCC115979,&H8026E297,&HF42E312D
    Data &H6842ADA7,&HC66A2B3B,&H12754CCC,&H782EF11C
    Data &H6A124237,&HB79251E7,&H6A1BBE6,&H4BFB6350
    Data &H1A6B1018,&H11CAEDFA,&H3D25BDD8,&HE2E1C3C9
    Data &H44421659,&HA121386,&HD90CEC6E,&HD5ABEA2A
    Data &H64AF674E,&HDA86A85F,&HBEBFE988,&H64E4C3FE
    Data &H9DBC8057,&HF0F7C086,&H60787BF8,&H6003604D
    Data &HD1FD8346,&HF6381FB0,&H7745AE04,&HD736FCCC
    Data &H83426B33,&HF01EAB71,&HB0804187,&H3C005E5F
    Data &H77A057BE,&HBDE8AE24,&H55464299,&HBF582E61
    Data &H4E58F48F,&HF2DDFDA2,&HF474EF38,&H8789BDC2
    Data &H5366F9C3,&HC8B38E74,&HB475F255,&H46FCD9B9
    Data &H7AEB2661,&H8B1DDF84,&H846A0E79,&H915F95E2
    Data &H466E598E,&H20B45770,&H8CD55591,&HC902DE4C
   
    Data &HB90BACE1,&HBB8205D0,&H11A86248,&H7574A99E
    Data &HB77F19B6,&HE0A9DC09,&H662D09A1,&HC4324633
    Data &HE85A1F02,&H9F0BE8C,&H4A99A025,&H1D6EFE10
    Data &H1AB93D1D,&HBA5A4DF,&HA186F20F,&H2868F169
    Data &HDCB7DA83,&H573906FE,&HA1E2CE9B,&H4FCD7F52
    Data &H50115E01,&HA70683FA,&HA002B5C4,&HDE6D027
    Data &H9AF88C27,&H773F8641,&HC3604C06,&H61A806B5
    Data &HF0177A28,&HC0F586E0,&H6058AA,&H30DC7D62
    Data &H11E69ED7,&H2338EA63,&H53C2DD94,&HC2C21634
    Data &HBBCBEE56,&H90BCB6DE,&HEBFC7DA1,&HCE591D76
    Data &H6F05E409,&H4B7C0188,&H39720A3D,&H7C927C24
    Data &H86E3725F,&H724D9DB9,&H1AC15BB4,&HD39EB8FC
    Data &HED545578,&H8FCA5B5,&HD83D7CD3,&H4DAD0FC4
    Data &H1E50EF5E,&HB161E6F8,&HA28514D9,&H6C51133C
    Data &H6FD5C7E7,&H56E14EC4,&H362ABFCE,&HDDC6C837
    Data &HD79A3234,&H92638212,&H670EFA8E,&H406000E0
   
    Data &H3A39CE37,&HD3FAF5CF,&HABC27737,&H5AC52D1B
    Data &H5CB0679E,&H4FA33742,&HD3822740,&H99BC9BBE
    Data &HD5118E9D,&HBF0F7315,&HD62D1C7E,&HC700C47B
    Data &HB78C1B6B,&H21A19045,&HB26EB1BE,&H6A366EB4
    Data &H5748AB2F,&HBC946E79,&HC6A376D2,&H6549C2C8
    Data &H530FF8EE,&H468DDE7D,&HD5730A1D,&H4CD04DC6
    Data &H2939BBDB,&HA9BA4650,&HAC9526E8,&HBE5EE304
    Data &HA1FAD5F0,&H6A2D519A,&H63EF8CE2,&H9A86EE22
    Data &HC089C2B8,&H43242EF6,&HA51E03AA,&H9CF2D0A4
    Data &H83C061BA,&H9BE96A4D,&H8FE51550,&HBA645BD6
    Data &H2826A2F9,&HA73A3AE1,&H4BA99586,&HEF5562E9
    Data &HC72FEFD3,&HF752F7DA,&H3F046F69,&H77FA0A59
    Data &H80E4A915,&H87B08601,&H9B09E6AD,&H3B3EE593
    Data &HE990FD5A,&H9E34D797,&H2CF0B7D9,&H22B8B51
    Data &H96D5AC3A,&H17DA67D,&HD1CF3ED6,&H7C7D2D28
    Data &H1F9F25CF,&HADF2B89B,&H5AD6B472,&H5A88F54C
   
    Data &HE029AC71,&HE019A5E6,&H47B0ACFD,&HED93FA9B
    Data &HE8D3C48D,&H283B57CC,&HF8D56629,&H79132E28
    Data &H785F0191,&HED756055,&HF7960E44,&HE3D35E8C
    Data &H15056DD4,&H88F46DBA,&H3A16125,&H564F0BD
    Data &HC3EB9E15,&H3C9057A2,&H97271AEC,&HA93A072A
    Data &H1B3F6D9B,&H1E6321F5,&HF59C66FB,&H26DCF319
    Data &H7533D928,&HB155FDF5,&H3563482,&H8ABA3CBB
    Data &H28517711,&HC20AD9F8,&HABCC5167,&HCCAD925F
    Data &H4DE81751,&H3830DC8E,&H379D5862,&H9320F991
    Data &HEA7A90C2,&HFB3E7BCE,&H5121CE64,&H774FBE32
    Data &HA8B6E37E,&HC3293D46,&H48DE5369,&H6413E680
    Data &HA2AE0810,&HDD6DB224,&H69852DFD,&H9072166
    Data &HB39A460A,&H6445C0DD,&H586CDECF,&H1C20C8AE
    Data &H5BBEF7DD,&H1B588D40,&HCCD2017F,&H6BB4E3BB
    Data &HDDA26A7E,&H3A59FF45,&H3E350A44,&HBCB4CDD5
    Data &H72EACEA8,&HFA6484BB,&H8D6612AE,&HBF3C6F47
   
    Data &HD29BE463,&H542F5D9E,&HAEC2771B,&HF64E6370
    Data &H740E0D8D,&HE75B1357,&HF8721671,&HAF537D5D
    Data &H4040CB08,&H4EB4E2CC,&H34D2466A,&H115AF84
    Data &HE1B00428,&H95983A1D,&H6B89FB4,&HCE6EA048
    Data &H6F3F3B82,&H3520AB82,&H11A1D4B,&H277227F8
    Data &H611560B1,&HE7933FDC,&HBB3A792B,&H344525BD
    Data &HA08839E1,&H51CE794B,&H2F32C9B7,&HA01FBAC9
    Data &HE01CC87E,&HBCC7D1F6,&HCF0111C3,&HA1E8AAC7
    Data &H1A908749,&HD44FBD9A,&HD0DADECB,&HD50ADA38
    Data &H339C32A,&HC6913667,&H8DF9317C,&HE0B12B4F
    Data &HF79E59B7,&H43F5BB3A,&HF2D519FF,&H27D9459C
    Data &HBF97222C,&H15E6FC2A,&HF91FC71,&H9B941525
    Data &HFAE59361,&HCEB69CEB,&HC2A86459,&H12BAA8D1
    Data &HB6C1075E,&HE3056A0C,&H10D25065,&HCB03A442
    Data &HE0EC6E0E,&H1698DB3B,&H4C98A0BE,&H3278E964
    Data &H9F1F9532,&HE0D392DF,&HD3A0342B,&H8971F21E
   
    Data &H1B0A7441,&H4BA3348C,&HC5BE7120,&HC37632D8
    Data &HDF359F8D,&H9B992F2E,&HE60B6F47,&HFE3F11D
    Data &HE54CDA54,&H1EDAD891,&HCE6279CF,&HCD3E7E6F
    Data &H1618B166,&HFD2C1D05,&H848FD2C5,&HF6FB2299
    Data &HF523F357,&HA6327623,&H93A83531,&H56CCCD02
    Data &HACF08162,&H5A75EBB5,&H6E163697,&H88D273CC
    Data &HDE966292,&H81B949D0,&H4C50901B,&H71C65614
    Data &HE6C6C7BD,&H327A140A,&H45E1D006,&HC3F27B9A
    Data &HC9AA53FD,&H62A80F00,&HBB25BFE2,&H35BDD2F6
    Data &H71126905,&HB2040222,&HB6CBCF7C,&HCD769C2B
    Data &H53113EC0,&H1640E3D3,&H38ABBD60,&H2547ADF0
    Data &HBA38209C,&HF746CE76,&H77AFA1C5,&H20756060
    Data &H85CBFE4E,&H8AE88DD8,&H7AAAF9B0,&H4CF9AA7E
    Data &H1948C25C,&H2FB8A8C,&H1C36AE4,&HD6EBE1F9
    Data &H90D4F869,&HA65CDEA0,&H3F09252D,&HC208E69F
    Data &HB74E6132,&HCE77E25B,&H578FDFE3,&H3AC372E6
Reply
#20
(02-24-2026, 12:49 PM)bplus Wrote: @SMcneill OK I didn't know you could do a Random Access without LEN in Open statement, was that in QB4.5?

It defaults to a LEN of 128.  Unless you specify the size, your records are going to be 128 bytes each.

The difference is in the variable type you use to write the data.   If you use a variable-length string, it writes the size first as a 2-byte integer.  Otherwise, since every other variable type is a set number of bytes, it just uses that size automatically and doesn't record those 2-bytes for you.

OPEN.... LEN = x

If you use variable length strings, they have to be a max of x - 2 bytes in length or you'll get errors.  Otherwise, any other data type has to be less than x bytes in length.   If LEN is not specified, then it defaults to 128.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Embedding and Extracting MANY files ! ahenry3068 20 1,490 11-15-2025, 10:19 AM
Last Post: ahenry3068
  random maze map. math help pmackay 4 551 08-10-2025, 11:22 AM
Last Post: pmackay
  Random Number Generator pmackay 14 1,231 07-30-2025, 12:56 PM
Last Post: SMcNeill
  generating a random number in the full range of that number? (Integer, Long) madscijr 2 641 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,282 10-24-2024, 06:08 PM
Last Post: madscijr

Forum Jump:


Users browsing this thread: