首页 > 解决方案 > DOSBox 中的 if 语句块与 Windows CMD 中的不同吗?

问题描述

我在 Windows 命令提示符 (CMD) 中创建了一个批处理文件,它可以工作。

考虑到 DOSBox 与 CMD 相同,我只是运行了相同的代码,但它不起作用。而且我注意到这些问题中所述可能存在一些差异。

这是批处理文件内容:

:: Hide commands
@echo off

:: Verbose usage
if "%1"=="" (
    echo Usage: tpc [file]
    echo file    a Turbo Pascal file
    goto eof
)

set file=%1
c:\tpwdb\bin\tpc %file%

echo.

echo Execute with %file%

:eof

在 CMD 中,它产生:

>tpc
Usage: tpc [file]
file    a Turbo Pascal file

>tpc 02\hellow.pas
This version of c:\tpwdb\bin\TPC.EXE is not compatible with the version of Windows you're running. Check your computer's system information and then contact the software publisher.

Execute with 02\hellow.pas

但在 DOSBox 中,它产生了:

>tpc
Illegal command: (.
Usage: tpc [file]
file    a Turbo Pascal file

>tpc 02\hellow.pas
Usage: tpc [file]
file    a Turbo Pascal file

这表明它没有识别 if block( )并且当有一个参数传递时,它仍然执行该块但没有显示 message Illegal command: (.

标签: batch-fileif-statementcmddosbox

解决方案


推荐阅读