|
-
Jan 5th, 2008, 04:37 PM
#3
Re: Change fields in UDT
Ugh. There is a much easier way.
In the New UDT, add a version member as the first member of the UDT, numerical or unique string.
Then simply open the file and read the first x bytes of the file to retrieve that version member.
If the first member of the Old & New UDTs are string Dates (10 bytes), this is simple. The version member of the new udt is a non date value, i.e., "Ver1". Now read the first 10 bytes into a string and use IsDate(). If it returns false, then it isn't a date and therefore the new version
Edited: This only solves the problem of which UDT to use for reading. If reading, using the the old UDT, and want to use the new UDT structure, you will have to convert from old to new. In future programs, it may be wise to simply append new members to a UDT vs trying to change member sizes. This is how Windows does it (most of the time). One version may read 10 members, but a newer version may read 15 members. The first member of a UDT is generally the size of the UDT. This way any app version can know where one udt starts & ends. Internally, the app knows how many bytes it needs per UDT for its purpose. The key difference here is that the UDT member sizes don't change, only the number of members change.
Last edited by LaVolpe; Jan 5th, 2008 at 04:57 PM.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|