batch-file - 批处理 : Simply Syntax Error : Goto was unexpected at this time

标签 batch-file cmd goto

所以我正在尝试编写一个基本的计算机程序。我在某些语法上遇到了一些麻烦。代码如下。

@echo off
cls
color 71
:start
echo        -----------------------------------
echo        Welcome to Tandy's Calculator! v0.1
echo        -----------------------------------
echo           Enter your first number below
echo Type "help" to see the list of available commands
echo        -----------------------------------
set /p "_input1=Please Enter The First Number or Command:"
cls
goto subroutine

:subroutine
:: the below line gives me the "goto was unexpected at this time" error
if /i "%_input1%"=="help" goto help1
if /i "%_input1%"=="back" goto _input1
if /i "%_input1%"=="clear" goto clearVar (
goto checkVar
)

每次执行该文件时都会收到错误 “此时 goto 是意外的”并且命令窗口关闭。

使用暂停命令,我已经能够查明收到错误消息的程序部分。这已经在程序中评论过了。

有人可以帮助我吗?我的语法有什么问题?

最佳答案

试试这个:

if /i "%_input1%"=="clear" goto clearVar
goto checkVar

这是无效的语法。

if /i "%_input1%"=="clear" goto clearVar (
goto checkVar
)

关于batch-file - 批处理 : Simply Syntax Error : Goto was unexpected at this time,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19308159/

相关文章:

xml - 如何复制一个元素(文本字符串)的内容并附加到另一个元素的内容? (XML)

windows - 批处理 TAB 分隔符还会在 ECHO 后删除字符 T、A 和 B

c++ - 用其他东西替换宏中的 goto

c++ - Goto 语句中的堆栈跟踪

c++ - Goto 无法正常工作 C++

windows - VLC 保存流到文件

powershell - teamcity powershell-无法运行批处理文件

windows - 将 "git describe --abbrev=0"结果获取到变量中

batch-file - 在bat文件中减去日期

windows - 调用 mvn tomcat :run in multiple projects/different directories using a batch file