Results 1 to 3 of 3

Thread: The result of bad coding

  1. #1

    Thread Starter
    Member
    Join Date
    Jan 2000
    Location
    Canada
    Posts
    34
    Greetings All,

    OK, as a newbie I finally did it! One of my program's functions is to create a few text based files. Then, ... ok let me show you how it is:

    File 1:
    =======
    [Profile]
    Run1=....
    Run2=....
    [Batch]
    Run1=...
    Run2=...


    File 2:
    =======
    [Profile]
    Run1=....
    Run2=....
    [Batch]
    Run1=...
    Run2=...


    File 3:
    =======
    [Profile]
    Run1=....
    Run2=....
    [Batch]
    Run1=...
    Run2=...


    Everything is just fine here but the last step is to create one file that contains all the above. That means:

    Final File:
    ===========
    [Profile]
    Run1=....
    Run2=....
    [Batch]
    Run1=...
    Run2=...
    Run3=...
    Run4=...
    Run5=...
    Run6=...


    But my final result looks like this:

    My Current File:
    ================
    [Profile]
    Run1=....
    Run2=....
    [Batch]
    Run1=...
    Run2=...
    [Profile]
    Run1=....
    Run2=....
    [Batch]
    Run1=...
    Run2=...
    [Profile]
    Run1=....
    Run2=....
    [Batch]
    Run1=...
    Run2=...

    I could have written the code to correct this problem earlier but as I said I am still a newbie! The [Profile] section is OK but I have no idea of any way of sorting out the [Batch] section. So, I really need help on this one.

    Any suggestion / recommendation would be greatly appreicated.
    Regards

  2. #2
    Frenzied Member Buzby's Avatar
    Join Date
    Jan 1999
    Location
    UK
    Posts
    1,670
    What you are actually creating is essentially an .INI file - eg

    [section]
    item=
    item=
    item=

    You really should be using the WritePrivateProfileString and GetPrivateProfileString API calls that handle .INI file creation - these look after the file grouping for you and make life a lot easier.
    Check out http://www.vb-world.net/files/tip17.html for more information.

    'Buzby'
    Visual Basic Developer
    "I'm moving to Theory. Everything works there."

  3. #3

    Thread Starter
    Member
    Join Date
    Jan 2000
    Location
    Canada
    Posts
    34
    Thank You for your reply.

    I was also wondering if there is a quick way of cleaning up the new text file and organize those sections.

    What I am thinking is to open the file, search for all different "Run" statements, sort them by number (Run1, Run2, etc), and put them under 2 sections, ie; [Profile] & [Batch].

    Is it possible? Thanks in advance.
    Regards

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