Results 1 to 4 of 4

Thread: [RESOLVED] Help with "Put"ing a UDT

  1. #1

    Thread Starter
    Hyperactive Member Teseng's Avatar
    Join Date
    Sep 2007
    Location
    Tupelo, MS
    Posts
    281

    Resolved [RESOLVED] Help with "Put"ing a UDT

    Type CustType
    Name as String
    Data() as Integer
    Dim Flags as Byte
    Dim Flags2 as Byte
    Dim Flags2 as Byte
    Data2() as Integer
    End Type

    Dim Custs(5) as CustType

    This is basically what i have in VB6, i write it to a file using

    Put FileNum, , Custs

    The problem is, i need to read this from another program, which is not coded in VB6, so i cant just use the same structure and use "get".

    Can anyone help me read this file (for now, from VB6, but pretending i dont have the structure, just reading the integers and stuff one at a time)

    I can get the Name, but the array of Integers, i cant figure out how it stores these in the file. Any help?

  2. #2
    Cumbrian Milk's Avatar
    Join Date
    Jan 2007
    Location
    0xDEADBEEF
    Posts
    2,448

    Re: Help with "Put"ing a UDT

    Can you post the file you want to read. It would really help if we could see it.

    Are you are Opening the files for Random or Binary?

    Are Data and Data2 always the same size or dynamic? If dynamic how does the file indicate the size?
    W o t . S i g

  3. #3
    Hyperactive Member
    Join Date
    Jun 2004
    Posts
    468

    Lightbulb Re: Help with "Put"ing a UDT

    How dynamic arrays (and other stuff) are stored is [mostly] explained in the documentation of the Put Statement.

    One of the key pieces of information is that saving a dynamic array writes a leading "descriptor" (which requires "2 + 8 * NumberOfDimensions" bytes) before the actual data. The first two bytes of the "descriptor" is the # of dimensions; and for each dimension, the first two bytes of the 8-byte "dimension descriptor" is the number of elements in that dimension. And since you already know the datatype of each element (Integer), you know how many bytes each array element uses (2 for an Integer). But if you didn't know the datatype (or if the datatype were Variant), that info is also stored (I leave it as an exercise for the reader ).

    To inspect a file, I'd suggest using a hex editor, such as XVI32. It'll make it easier to verify the contents and validate your understanding.

  4. #4

    Thread Starter
    Hyperactive Member Teseng's Avatar
    Join Date
    Sep 2007
    Location
    Tupelo, MS
    Posts
    281

    Re: Help with "Put"ing a UDT

    Ah, the descriptor stuff is what i was looking for! Thanks very much guys.

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