Results 1 to 5 of 5

Thread: binary file

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Oct 2000
    Location
    California, USA
    Posts
    111

    Unhappy

    I have a variable-length record that is written to a file every second from another program. The vb program is supposed to get the new record and update the form with the info. Is there a way to get the newly-written record without having to read from the top of the file each time? Thanks.

  2. #2
    Frenzied Member
    Join Date
    Jan 2000
    Location
    Bellevue, WA, USA
    Posts
    1,357
    Why don't you just have the program that writes the file OVERWRITE the previous information. Then you will only have to read one line each time.
    ~seaweed

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Oct 2000
    Location
    California, USA
    Posts
    111
    I need the previous records for later references.

  4. #4
    Frenzied Member
    Join Date
    Jan 2000
    Location
    Bellevue, WA, USA
    Posts
    1,357

    Another Idea

    I know this isn't really answering your question, but perhaps you could do this:

    1) Write the record to a "master file"
    2) Write the record to a "latest record" file
    3) Read records from "latest record" file, display info, and delete the file

    This way, you are only reading the records you haven't yet retrieved, yet you retain a master file of all the records that have been written.

    Another idea is to use a database and ADO instead of a text or binary file. With a database, you can manipulate the recordset cursor and simply "MoveLast" to retrieve the last record, or "Find" the primary key of the record just after the last record you read. This way you don't have to start from the beginning and read through each record.

    Just a few thoughts,
    ~seaweed

  5. #5
    Guest
    I can't remember the length of variable (how many bytes). If we think it's 8 bytes and you've a header in the file that is 32 bytes long, you could read the latest one like this:

    Get #1, 33 + 8 * NumberOfRecords, Record

    If the record is last in the file, you could also try following:

    Get #1, LOF(1) - 8, LastRecord

    Hope this helps,

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width