Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

how to parser the config file

2 views
Skip to first unread message

thinktwice

unread,
May 5, 2008, 5:18:31 AM5/5/08
to
here is my config file:
//config.ini
WORKINGDIR=C:\workspace
LOGDIR=C:\log
BUILDDIR=C:\build

for /f "tokens=1,2 delims==" %%i in ('findstr /c:WORKINGDIR=
config.ini') do @set WORKINGDIR=%%j
for /f "tokens=1,2 delims==" %%i in ('findstr /c:LOGDIR= config.ini')
do @set LOGDIR=%%j
for /f "tokens=1,2 delims==" %%i in ('findstr /c:BUILDDIR=
config.ini') do @set BUILDDIR=%%j

but it doesnt work as i think.

findstr /c:WORKINGDIR config.ini
returns "LOGDIR=C:\loge"
i don't know why it returns the next line of my target line? why it
returns C:\loge but not c:\log???

thinktwice

unread,
May 5, 2008, 5:30:56 AM5/5/08
to
finally i find it's caused by my textedtior, :-/

Tom Lavedas

unread,
May 5, 2008, 8:50:33 AM5/5/08
to

I suppose this is off target, but a comment about your use of the
config file: As you have constructed it, I would think this is a bit
more efficient way to use it ...

for /f "tokens=*" %%a in (config.ini) do set "%%a"

It works as long as the equations are built without spaces around the
equal signs (and without section headers). Actually, there will be no
errors, even if you use spaces. It's just that the variables will be
named in unexpected ways - with trailing spaces - and the contents
will also contain (leading) spaces.

Tom Lavedas
===========
http://members.cox.net/tglbatch/wsh/

Tom Lavedas
===========
http://members.cox.net/tglbatch/wsh/

0 new messages