Reputation: 831
I have this code:
SETLOCAL enabledelayedexpansion enableextensions
SET OutofService=Weblog_Doc(file:///C:/Bla/BlaKon.htm?send=2000)
REM - Declare and set the Array
FOR /f "delims=" %%a IN (C:\Folder1\log.dat) DO (
SET /a c+=1
SET x[!c!]=%%a
)
REM - Read Array from end to start
FOR /l %%I IN (!c! -1 1) DO (
SET _result=!x[%%I]:~-47%!
ECHO !_result!
ECHO !OutofService!
IF "!_result!"=="!OutofService!" (
ECHO yahooo!
)
)
The string in file log.dat
is as follows:
09/17/15 15:18:52:577 Container:
Weblog_Doc(file:///C:/Bla/BlaKon.htm?send=2000)
My ECHO
statement is outputting the result:
Weblog_Doc(file:///C:/Bla/BlaKon.htm?send=2000)
Weblog_Doc(file:///C:/Bla/BlaKon.htm?send=2000)
The if
statement is returning false
and not outputting yahooo!
as it should, given the fact that these two strings should be equal. What am I doing wrong?
Upvotes: 1
Views: 562
Reputation: 70961
SET x[!c!]=%%a
^^^^^^^^^^ Spaces included in value
....
SET _result=!x[%%I]:~-47%!
^^^^^^ Spaces included in value
Try with (percent sign in the third line is not needed)
SET "OutofService=Weblog_Doc(file:///C:/Bla/BlaKon.htm?send=2000)"
....
SET "x[!c!]=%%a"
....
SET "_result=!x[%%I]:~-47!"
This way, while the assignment operation is quoted, the quotes are not included in the value, nor the ending spaces if present.
Upvotes: 1