1.

Solve : Logical OR operator?

Answer»

This is what I'm trying to do:
Code: [Select]IF "%win_version%"=="xp" | "%win_version%"=="2000" | "%win_version%"=="2003" | "%win_version%"=="nt" (ECHO Hurray!)

It works when I only have one condition (IF "%win_version%"=="xp" ) but I need to check for a few more and if either is true, do something. You need different if statements.
If "%var%"=="XP" echo hooray
if "%var%"=="2000" echo hooray
...Here is a workaround
Code: [Select]set bool=0
IF "%win_version%"=="xp" set /a bool+=1
IF "%win_version%"=="2000" set /a bool+=1
IF "%win_version%"=="2003" set /a bool+=1
IF "%win_version%"=="nt" set /a bool+=1
IF %bool% GTR 0 (
    ECHO Hurray!
    ECHO Suitable version
    )
Ah, so there isn't a logical OR.

Thank you for your help, that workaround looks promising. QUOTE from: Kolya on April 13, 2010, 04:10:53 PM

Ah, so there isn't a logical OR.
Or as an alternative, you can learn a different language that has better support for such things and more, EG Python
Code: [Select]>>> versions=("xp","2000","2003","nt","here","you","can","add","more","different","checks","etc","etc","etc")
>>> if win_version in versions:  print "hurray, suitable version"
     

Quote from: ghostdog74 on April 13, 2010, 05:54:39 PM
you can learn a different language

What a surprise! I wasn't expecting that!  Quote from: Salmon Trout on April 14, 2010, 12:00:02 AM
What a surprise! I wasn't expecting that! 
Salmon...!I'm fairly certain Ghostdog is now mentioning alternatives such as python, grep, SED, etc. just because he knows it annoys ST, heh.

And hey! here's the BEST part about the python approach! it's cross-platform! now you can check what version of windows you have installed on Ubuntu!    Quote from: BC_Programmer on April 14, 2010, 06:21:29 AM
I'm fairly certain Ghostdog is now mentioning alternatives such as python, grep, sed, etc. just because he knows it annoys ST, heh.
no, i am not. I have been suggesting alternatives long time ago using vbscript, Perl , Python etc. and no, remember, my posts are never meant for anyone else but the OP. They are 100% for the OP to solve his problem. Whether one is "annoyed" or not, I don't care.

Quote
And hey! here's the best part about the python approach! it's cross-platform! now you can check what version of windows you have installed on Ubuntu!   
i am assuming you are joking.


Discussion

No Comment Found