在IF语句WinXP的批处理脚本使用OR [英] Using an OR in an IF statement WinXP Batch Script
本文介绍了在IF语句WinXP的批处理脚本使用OR的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
有没有办法通过一个IF语句传递一个OR?
如:
SET VAR =两个
IF%VAR%==一或二或三化呼应数为零至四个。
解决方案
没有。
如果VAR%%==一转到富
如果%VAR%==二转到富
如果%VAR%==三防转到富
转到afterfoo
:富
回波的数目是一个和三个之间(技术上不正确的,因为它包括了终点,因而是不之间)。
:afterfoo
如果你需要一个更结构化的方法:
如果VAR%%==一设置OneToThree = 1
如果%VAR%==二设置OneToThree = 1
如果%VAR%==三化设置OneToThree = 1
如果定义OneToThree(
回声富
)其他(
REM的东西
)
Is there a way to pass an OR through an IF statement?
Such as:
SET var=two
IF "%var%"=="one" OR "two" OR "three" ECHO The number is between zero and four.
解决方案
No.
if "%var%"=="one" goto foo
if "%var%"=="two" goto foo
if "%var%"=="three" goto foo
goto afterfoo
:foo
echo The number is between one and three (technically incorrect, since it includes the end points and thus is not between).
:afterfoo
If you need a more structured approach:
if "%var%"=="one" set OneToThree=1
if "%var%"=="two" set OneToThree=1
if "%var%"=="three" set OneToThree=1
if defined OneToThree (
echo Foo
) else (
rem something
)
这篇关于在IF语句WinXP的批处理脚本使用OR的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文