Page 1 of 1

Need some help with a menu

Posted: 21 Aug 2012 16:45
by leftybeaver128
Hello all,
I'm having a bit of trouble getting my menu setup to work. When I select a choice, it just gives me the "Error. Please select a valid choice" text that I setup.

Can someone please tell me what's going wrong?

Thanks!

Here is a block of code that has the problem.

Code: Select all

:mainMenu
cls
echo ---Backup Manager----------
echo Version %VERSION%
echo.
echo.
echo Menu
echo ------
echo 1 View Current Backups
echo 2 Add a Backup
echo 3 Delete a Backup
echo 4 Legal
echo 5 Changelog
echo 6 Reinstall
echo Exit
echo.
set /p '%choice%'=(Please select an option)
if '%choice%'=='1' goto backupList
if '%choice%'=='2' goto backupAdd
if '%choice%'=='3' goto backupDelete
if '%choice%'=='4' goto legal
if '%choice%'=='5' goto changelog
if '%choice%'=='6' goto setup
echo Error, please select a valid choice.
pause>nul
goto mainMenu

Re: Need some help with a menu

Posted: 21 Aug 2012 16:59
by abc0502
replace all single qoute with double one

From

Code: Select all

if '%choice%'=='1' goto backupList

To

Code: Select all

if "%choice%"=="1" goto backupList


and this line

Code: Select all

set /p '%choice%'=(Please select an option)

to

Code: Select all

set /p "choice=(Please select an option)"


In Dos use double qoutes " " not ' '

Re: Need some help with a menu

Posted: 21 Aug 2012 23:18
by foxidrive
leftybeaver128 wrote:

Code: Select all

set /p '%choice%'=(Please select an option)


Remove the ' and % characters. You need to use a simple variable name here.


The double quotes are useful too:

set /p "choice=(Please select an option): "