254Views10Replies
Is it just me or this doesn't work..batch?
I tried making a batch and it looks something like this (it is a subsystem)Bold words need paying attention to:
:mainmenu
echo choose your selection:
echo 1 apps
echo 2 editor
echo 3 phun not done
echo 4 sites not done
set /p choice=
if %choice%==1 goto :apps
if %choice%==2 goto editor
if %choice%==3
if %choice%==4
echo error wrong choice
pause
goto mainmenu
I would like to KNOW the goto and heading does not work! Please tell, I need it for my subsystem and you will recieve credit for it when I post the 'ible
UPDATE Does 3 and 4 have to be filled in?
Discussions
8 years ago
I think 3 and 4 do need to be filled in. Perhaps try:
if %choice%==3 goto mainmenu
if %choice%==4 goto mainmenu
Also,
if %choice%==1 goto apps
instead of:
if %choice%==1 goto :apps
although it shouldn't really matter.
10 years ago
This isn't finished - no :apps or :editor - what exactly are you asking about?
L
Answer 10 years ago
I know it is does not work in this form, It's pulled from a 408- lined batch document you don't expect me to paste it do you?, leave that I was asking why won't the batch document goto the top when you enter a wrong number in the set /p choice bit
Answer 10 years ago
You're missing a colon? Or is that a typing error on this page?
L
Answer 10 years ago
Typing error
Answer 10 years ago
and the first goto :apps, then goto editor - no colon. Have to keep the syntax straight.
Answer 10 years ago
Yes I noticed that, but as g-one also observes it's a job half-done.
L
10 years ago
set choice=
you can't enter something
set /p choice=
if %choice%==3
if %choice%==4
your batch will crash because a command is expected, e.g.
if %choice%==3 echo 3 was entered
if %choice%==4 echo 4 was entered
Answer 10 years ago
I did this wrong you seem to be right but it was meant to be set /p chioce, I couldn't paste words for some reason so I had to retype it and made errors, Ill change it
Answer 10 years ago
Thanx Ill get up to checking it