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:
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
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?

sort by: active | newest | oldest
I think 3 and 4 do need to be filled in. Perhaps try:

if %choice%==3 goto mainmenu
if %choice%==4 goto mainmenu


if %choice%==1 goto apps

instead of:

if %choice%==1 goto :apps

although it shouldn't really matter.
lemonie7 years ago
This isn't finished - no :apps or :editor - what exactly are you asking about?

knex_mepalm (author)  lemonie7 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

You're missing a colon? Or is that a typing error on this page?

knex_mepalm (author)  lemonie7 years ago
 Typing error
and the first goto :apps, then goto editor - no colon.  Have to keep the syntax straight.
Yes I noticed that, but as g-one also observes it's a job half-done.

g-one7 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
knex_mepalm (author)  g-one7 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
knex_mepalm (author)  g-one7 years ago
Thanx Ill get up to checking it