2012-02-04 66 views
-1

幫助。設置menuInput後,這不起作用。它總是隻去:opties。 (如果一個類型A,B,C或其他任何東西。誰能說我有什麼錯?從蝙蝠開始:輸入 - > goto不工作

@ECHO off 

:hoofdMenu 
::Dit is het hoofd menu. 
title Hoofdmenu 
echo A. Opties 
echo B. Starten van game 
echo C. Stop programma 
set /P menuInput="Maak een keuze:" 
if %menuInput% == "a" goto opties 
if %menuInput% == "b" goto spelStarten 
if %menuInput% == "c" goto exit 

:opties 
::Geeft alle opties weer -> menu van de opties 
title Opties 
cls 
echo Op dit momment zijn er nog geen opties mogelijk. Sorry. 
pause 
cls 
goto :hoofdMenu 

:spelStarten 
::Starten van het spel 
cls 
title Het spel 
echo Dit is nog in de maak 
pause 
cls 
goto :hoofdMenu 

:exit 
::Sluit het programma 
exit 
+0

請在此發佈您的代碼,並提供更多詳細信息。 – 2012-02-04 18:46:28

回答

2

批處理文件是不是所有的現代編程languagues那麼寬容。在這裏你去。

if %menuInput%==a goto opties 
if %menuInput%==b goto spelStarten 
if %menuInput%==c goto exit 

不如果你使用的是Windows Vista或更高版本,你應該看看choice命令,這個命令允許你指定允許的字符,而且你不必處理他們按錯了鍵的機會它還有其他一些便利的功能。

+0

謝謝!最好的評論。 =) – 2012-02-04 19:26:42

+0

或者,您可以使用'「%menuInput%」==「a」'等來防止輸入爲空時的錯誤。 – schnaader 2012-02-04 19:36:24