batch-file – 在IF语句WinXP Batch Script中使用OR
发布时间:2020-12-14 04:18:03 所属栏目:Windows 来源:网络整理
导读:有没有办法通过IF语句传递OR? 如: SET var=twoIF "%var%"=="one" OR "two" OR "three" ECHO The number is between zero and four. 没有. if "%var%"=="one" goto fooif "%var%"=="two" goto fooif "%var%"=="three" goto foogoto afterfoo:fooecho The nu
有没有办法通过IF语句传递OR?
如: SET var=two IF "%var%"=="one" OR "two" OR "three" ECHO The number is between zero and four.
没有.
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 "%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 ) (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |