|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Update a structure when another structure changesrecord? 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! Thelonious Monk wrote:
Show quoteHide quote >Is there a way to update two structures when you use a FileGet to read a mid(str1,start,length)>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! > > > > T "tomb" <t***@technetcenter.com> wrote in message I would have to write a Mid statement for each field. I have a bunch. I news:CiqBg.183$ID1.107@bignews2.bellsouth.net... >> > mid(str1,start,length) > > T would like the process to be done automatically, if possible. 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. -Boo |
|||||||||||||||||||||||