所以我正在尝试编写一个基本的计算机程序。我在某些语法上遇到了一些麻烦。代码如下。
@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/