如何在DOS 6.22中使用CALL功能?

时间:2014-02-21 17:06:05

标签: batch-file dos

我编写了一个在Windows命令提示符下运行正常的批处理文件,但我希望能够在DOS下POST后运行它。我已将我的代码复制到AUTOEXEC.BAT文件中,该文件自动执行;但是一旦它到达call命令就会出现语法错误。

echo. This script is counting the # of POSTs.
echo. The POST # value is saved in TEST.txt.
echo.

call:myPOSTTest

for /f "tokens=* delims=" %%x in (A:\TEST.txt)  do echo POST# %%x

echo. &pause&goto:eof
::--------------------------------------------------------
::-- Function section starts below here
::--------------------------------------------------------

:myPOSTTest    - here starts my function identified by its label 

set var=0

if EXIST A:\TEST.txt (
     for /f %%x in (A:\TEST.txt) do (set /a var=%%x+1)
)

echo %var% >> A:\TEST.txt

goto END

:END

谢谢

1 个答案:

答案 0 :(得分:0)

见以下评论:

echo. This script is counting the # of POSTs.
echo. The POST # value is saved in TEST.txt.
echo.

call:myPOSTTest

MSDOS不支持call:label语法

for /f "tokens=* delims=" %%x in (A:\TEST.txt)  do echo POST# %%x

MSDOS不支持扩展for命令

echo. &pause&goto:eof

MSDOS不支持&命令分隔符或goto :eof链接

::--------------------------------------------------------
::-- Function section starts below here
::--------------------------------------------------------

:myPOSTTest    - here starts my function identified by its label 

set var=0

if EXIST A:\TEST.txt (
     for /f %%x in (A:\TEST.txt) do (set /a var=%%x+1)
)

MSDOS不支持括号中的复合表达式或set /a增强

echo %var% >> A:\TEST.txt

goto END

:END