Update a structure when another structure changes

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Thelonious Monk

    #1

    Update a structure when another structure changes

    Is there a way to update two structures when you use a FileGet to read a
    record? For example:

    Public Structure MyRecordStructu re
    <VBFixedString( 517)Dim All_Of_Record as String
    End Structure

    Public Structure Record1_Structu re
    <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_Structu re
    <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
  • tomb

    #2
    Re: Update a structure when another structure changes

    Thelonious Monk wrote:
    >Is there a way to update two structures when you use a FileGet to read a
    >record? For example:
    >
    Public Structure MyRecordStructu re
    <VBFixedString( 517)Dim All_Of_Record as String
    End Structure
    >
    Public Structure Record1_Structu re
    <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_Structu re
    <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 MyRecordStructu re
    Dim Record_Type1 as Record1_Structu re
    Dim Record_Type2 as Record2_Structu re
    >
    .
    .
    .
    InputCh = FreeFile
    FileOpen(InputC h, "c:\this\is\my\ file", OpenMode.Random ,
    >OpenAccess.Def ault, OpenShare.Share d, 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!
    >
    >
    >
    >
    mid(str1,start, length)

    T

    Comment

    • Thelonious Monk

      #3
      Re: Update a structure when another structure changes

      "tomb" <tomb@technetce nter.comwrote in message
      news:CiqBg.183$ ID1.107@bignews 2.bellsouth.net ...
      >>
      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.


      Comment

      • GhostInAK

        #4
        Re: Update a structure when another structure changes

        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.ToSo meOtherStruct() .. which would provide a copy of the data
        in a diff format.

        -Boo


        Comment

        Working...