2

だから私は基本的なコンピュータプログラムを書こうとしています。そして、いくつかの構文で少し問題があります。コードは次のとおりです。

@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 は現時点では予想外でした」というエラーが表示され、コマンド ウィンドウが閉じます。

一時停止コマンドを使用して、エラー メッセージが表示されるプログラムの部分を特定できました。これは番組内でコメント済み。

誰でも私を助けることができますか?構文の何が問題になっていますか?

4

3 に答える 3

2

これを試して:

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

これは無効な構文です。

if /i "%_input1%"=="clear" goto clearVar (
goto checkVar
)
于 2013-10-11T01:04:37.423 に答える
1

これも試してください:

if /i "%_input1%"=="clean" (
    goto cleanVar
) ELSE (
    goto checkVar
)
于 2014-02-02T10:14:42.367 に答える