Computing.Net > Forums > Disk Operating System > Strange String Comparison

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Click here to start participating now! Also, check out the New User Guide.

Strange String Comparison

Reply to Message Icon

Name: karnso
Date: September 25, 2002 at 12:47:36 Pacific
OS: WinNT4.0
CPU/Ram: 256
Comment:

This is weird. I am having a strange problem
I have a file which contains :

---------- TEMP.TXT
CODEX=6

I am trying to find the codex value.
In a batch file, i use this (suggested by Secret Doom)

for /F "tokens=2 delims==" %%I in (T1.DAT) do (
echo %%I
IF %%I "==" ECHO UUUIJUI
if %I%=="6" echo six
)

The for loop does not work at all for any string comparison. The "ECHO %%I" variable displays "6", but i cannot do any comaparison after that.

Please Help,
Kenny.



Sponsored Link
Ads by Google

Response Number 1
Name: Secret_Doom
Date: September 25, 2002 at 13:56:07 Pacific
Reply:

Let's see the comparisons one by one. First IF statement:

IF %%I "==" ECHO UUUIJUI

That will display the message "UUUIJUI" on the screen if %%I is nothing. Though that space between %%I and the first quote seems weird, it works. Perhaps that's not what you wanted it to do, but it makes what it is supposed to. Second IF statement:

if %I%=="6" echo six

It's %%I, not %I%. Another thing, it will only return a TRUE value (and execute the ECHO cmd) if %%I is "6", including the quotes. The file would have to contain, for instance:

CODEX="6"

I believe you wanted to do this:

if "%%I"=="6" echo six

That will execute the ECHO cmd if %%I is 6 (as in your example of TEMP.TXT).

-- Leonardo Pignataro - Secret_Doom --

secret_doom@hotmail.com
www.batch.hpg.com.br


0

Response Number 2
Name: karnso
Date: October 1, 2002 at 10:37:31 Pacific
Reply:

Thanks..


0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More


Can't install Win ME from... olivetti jp190 dos driver...



Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Disk Operating System Forum Home


Sponsored links

Ads by Google


Results for: Strange String Comparison

Parse BAS files... www.computing.net/answers/dos/parse-bas-files/12483.html

Parse string in Win9x DOS www.computing.net/answers/dos/parse-string-in-win9x-dos/14876.html

String manipulation www.computing.net/answers/dos/string-manipulation/11933.html