Announcement

Collapse
No announcement yet.

Is this safe?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Tom Hanlin
    replied
    The RANDOM file mode is designed for records of a single fixed length. It sounds like what you want is a BINARY file.

    ------------------
    Tom Hanlin
    PowerBASIC Staff

    Leave a comment:


  • Edwin Knoppert
    replied
    For files it might work.
    However you don't want that.

    Test:

    Create a for binary opened file (0 bytes)
    Then use PUT #1, 100000, a$

    Close and take a closer look.
    A memory (garbage) dump is put in the file!
    If you create files be sure you fill them with chr$( 0 )
    So, i can imagne your 'random' structure will also fill your file.

    If your file has a correct length i suggest using the original structure and use a pointer or use poke$ and Peek$




    ------------------
    [email protected]

    Leave a comment:


  • Guest's Avatar
    Guest started a topic Is this safe?

    Is this safe?

    Hello,


    If you open a file in random mode and set the record length to 2048,
    is it safe to read a record into a structure that is smaller than
    the record length?

    Code:
    type CRecord
        m_WellNumber as long
        m_Pointer as long
    end type
    
    dim MyRecord as CRecord
    
    open"database.db" for random as #1 len = 2048
    get #1,seek(1),MyRecord
    Thanks...

    ------------------
    Cheers
Working...
X