典型批处理语句摘录

1.条件判断语句

if /I not "%1" == "norel" goto DoneChkNoRel

set _BLDDEMO_NOREL=1

shift

goto ParseArgs

:DoneChkNoRel

 

2.测试提示语句

if not "%_BLDDEMO_NUKE%"=="" echo Nuke option specified

 

3.输入命令行参数处理的典型流程:

       @REM // Parse the arguments

       :loop_1

              @REM // switch %1

              if not "%1"=="-r" goto endcas_1

                     set WINCEREL=%___OLDWINCEREL%

              goto endswt_1

              :endcas_1

              if not "%1"=="-l" goto endcas_2

                     set __QBLDLOCAL=1

              goto endswt_1

              :endcas_2

              if not "%1"=="-q" goto endcas_3

                     echo CEBUILD: Skipping directly to SYSGEN phase

                     set __QBLDQUICK=1

              goto endswt_1

              :endcas_3

                     @REM // all done

                     goto endloop_1

              :endswt_1

              shift

       goto loop_1

       :endloop_1

 

4.实现变量包含多个参数顺序的倒序流程

set _REV_DEPTREES=

for %%f in (%_DEPTREES%) do call :AddRevDepTree %%f

echo _DEPTREES="%_DEPTREES%"

echo _REV_DEPTREES="%_REV_DEPTREES%"

…….

:AddRevDepTree

    if not "%_REV_DEPTREES%" == "" set _REV_DEPTREES=%1 %_REV_DEPTREES%

    if "%_REV_DEPTREES%" == "" set _REV_DEPTREES=%1

    goto :EOF

你可能感兴趣的:(典型批处理语句摘录)