Computer Hope
Microsoft => Microsoft DOS => Topic started by: On40 on February 11, 2009, 01:00:58 AM
-
Well, i lost the technique after some month's of gaming.
I tryed to do this:
@echo off
title Test menu
color F0
:Menu
echo Test menu.
echo --------------
echo 1. echo weeeeeeeeeeeeeeeeee it works
echo 2. quit
set /p input=Input:
if 'input' == '1' goto wee
if 'input' == '2' exit
:wee
echo weeeeeeeeeeeeeeeeee it works
pause
quit
I didnt work, it just skipped everything and said wee paused and quitted. :P
What did i do wrong?
-
if /i %input%==1 goto :wee
-
I would change Carbon's code slightly. You don't really need the /i because we are only comparing numbers. I would also add brackets (or quotes) to the comparisons, otherwise, if the user just presses [Enter] the variable would be blank and the batch file would probably exit with an error.
if {%input%}=={1} goto :wee
Also, I don't think QUIT is not an internal command or standard external command. I would probably change that to
goto :EOF
-
If you want the batch file to close, it does that automatically at the end of the script.
Otherwise, the correct command is exit
-
actually, the GOTO :EOF is better- if they start the batch from the command-line, then the exit command will close that command interpreter instance on them. whereas the goto will go to the end of the file and the command interpreter will be returned control.
-
Ok thanks :) Trying to see if it works. Man sorry for gravedigging. I just went on some skiing trip.