fhillipo
Mon Nov 29 01:01:07 CST 2004
Thanks so much. What I did originally was what you spelt out in option 2. I
get new lines written but I need only 1 line of 'CASE_X=???' with the
original 'ABC' update to 'XYZ'. I can read from ini files and I can write to
it but I'm struggling with updating values already written or if that's not
feasible deleting content of a section before writing the new line. Looking
4ward ti reading from you.
"mayayana" wrote:
> It's awkward to do. The two options are 1) to
> read out one line at a time and then rewrite the file
> from those lines, replacing the line with the value in
> question. Or 2) use Instr to find "CASE_X=", then
> use InStr to find the end of that line, then concatenate
> the first part (up to "CASE_X=") with your new value
> and the rest of the file (following the vbCrLf at the
> end of that line.
>
> This download may be useful:
>
http://www.jsware.net/jsware/scripts.html#classpk
>
> It includes a class for reading and writing with INI
> files. The class is created as an object and provides
> all the basic INI file operations. It works by reading
> the whole INI file out into a Dictionary object for easy
> access to all keys and values.
>
> --
> _____________________________
>
> mayayXXana1a@mindYYspring.com
> For return email remove XX and YY.
> _____________________________
> fhillipo <fhillipo@discussions.microsoft.com> wrote in message
> news:CA722256-B05C-47CC-BF23-751CE9947738@microsoft.com...
> > I need to write a string value to a section of an ini file. I managed to
> > write to it but it appends to existing values. I need to either edit the
> > current value or delete the values in the section in question before I
> write
> > new values
> >
> > For example:
> >
> > file ="C:\VBS\myConfig.ini"
> > Section = "ORACLE TO SQL SERVER"
> > item = "CASE_X"
> > Value = "XYZ"
> >
> > ini file output:
> >
> > [ORACLE TO SQL SERVER]
> > CASE_X=ABC
> > CASE_X=XYZ
> > CASE_X=XYZ
> > DB_NAME=YYY
> > LSNAME=orclDB
> > DTSERROR_O2S="C:\sqlConfig\dtsError\orcl_2_mssql\xxx.txt"
> >
> > How do I edit the original value of ABC to XYZ without having to write new
> > lines as I need only I line for CASE_X Values. Any input would be greatly
> > apreciated
> >
> > --
> > fhillipo
>
>
>