Is there a way to update two structures when you use a FileGet to read a
record? For example:
Public Structure MyRecordStructure
<VBFixedString(517)> Dim All_Of_Record as String
End Structure
Public Structure Record1_Structure
<VBFixedString(1)> Dim Record_Type as String
<VBFixedString(30)> Dim CustomerName as String
<VBFixedString(486)> Dim Rest_Of_Record as String
End Structure
Public Structure Record2_Structure
<VBFixedString(1)> Dim Record_Type as String
<VBFixedString(8)> Dim CustomerNumber as String
<VBFixedString(30)>Dim CustomerAddress as String
<VBFixedString(478)> Dim Rest_Of_Record as String
End Structure
.
.
.
.
Dim MyInputRecord as MyRecordStructure
Dim Record_Type1 as Record1_Structure
Dim Record_Type2 as Record2_Structure
.
.
.
InputCh = FreeFile
FileOpen(InputCh, "c:\this\is\my\file", OpenMode.Random,
OpenAccess.Default, OpenShare.Shared, 517)
Do While Not EOF(InputCh)
FileGet(InputCh, MyInputRecord)
'
' Map the contents of MyInputRecord to Record_Type1 and
Record_Type2
'
.
.
.
End While
The FileGet method reads information into a structure that you have
declared. What I'm trying to accomplish is an automatic mapping of one
record structure (MyInputRecord) to Record_Type1 and Record_Type2, similar
to how languages such as COBOL does it. Each record in my file is 517
characters in length without any termination in the record (i.e. no
CHR(13)). Can someone offer any useful suggestions?
Thanks!
tomb - 06 Aug 2006 19:10 GMT
>Is there a way to update two structures when you use a FileGet to read a
>record? For example:
[quoted text clipped - 50 lines]
>
>
mid(str1,start,length)
T
Thelonious Monk - 06 Aug 2006 20:04 GMT
> mid(str1,start,length)
>
> T
I would have to write a Mid statement for each field. I have a bunch. I
would like the process to be done automatically, if possible.
GhostInAK - 06 Aug 2006 23:32 GMT
Hello Thelonious,
Since, as you say, you have fixed-length records.. how about just one structure..
The one that has the most level of detail.
Then you can add properties and/or methods for accessing the data in any
way you choose. You might even create your other structures (if you really
have need of them) and provide conversion functions off the main struct..
like MainStruct.ToSomeOtherStruct().. which would provide a copy of the data
in a diff format.
-Bo