Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/batch-file/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Batch file 如何在DOS 6.22中使用调用函数?_Batch File_Dos - Fatal编程技术网

Batch file 如何在DOS 6.22中使用调用函数?

Batch file 如何在DOS 6.22中使用调用函数?,batch-file,dos,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="

我已经编写了一个批处理文件,在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

谢谢

请参见下面的评论:

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

我认为它没有在那里实施。但不是100%确定…出于好奇,你正在运行什么版本的Windows?您提到过在Windows命令提示符下运行它,但您希望在DOS中运行它……我认为DOS6.22不支持批处理文件中的函数。但是,您可以在外部批处理文件上调用othercmd.bat。我还修改了一个WinPE,它可以毫无问题地执行批处理文件,但需要3到4分钟。DOS快得多。call命令在DOS6.22中运行时返回语法错误