0
@echo off
title Variables
set age= default
set name = defualt
set teaornah = deafault
set transport = deafault
echo How old are you, my fine friend?
set /p age=
echo So, you are %age% years old? Interesting!
pause
echo And what might your namesake be, old fellow?
set /p name=
echo Oh that's right! It's %name%! I'm am absolutly HORRID with names! Dear me!
pause
echo so, %name%, would you like to go to get some tea?
set /p teaornah=
if %teaornah% == yes goto yes
if %teaornah% == no goto no
:yes
echo very well then!
echo Would you like to take a bus or car?
set /p transport=
if transport == car goto car
if transport == bus goto bus
:car
echo we seem to be caught up in a traffic jam.
echo how awful.
echo fine weather, huh?
echo you're not very talkative.
echo goodbye.
pause
exit
:bus
echo You are victorious, %name%!
pause
exit
:no
echo Oh. How bad. I think I shall kill you now.
pause
exit
這是我的代碼。我是一名初學者批量用戶,剛學過goto命令,但是當在set/p transport =之後輸入「bus」時,它不會去:bus去:car。我想要一些幫助,因爲我發現與其他程序有類似的問題。 goto:沒有作品,goto也沒有:是的,但沒有其他goto的作品。請幫忙!「GOTO」命令有什麼問題?
當然可以。 OP也應該知道'set'是空間敏感的,所以'set name = defualt'會設置一個名爲「name」而不是「name」的變量。此外,語法'if/i「%var%」==「值」'優先選擇,因爲引號解析了其值包含分隔符(如空格)的變量。 '/ i'使比較不區分大小寫。 – Magoo 2014-12-13 00:56:59
@Magoo剛剛走出了工作之門,但這是答案材料(即使它沒有按照問題回答問題)。你可以編輯一些副本到我的答案? – 2014-12-13 00:58:10