-
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.
-
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.
-
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.