[Solved] input to start a program not working...

Score
0
Vote Up
February 9, 2012 at 17:00:25 Pacific
Specs: Windows Vista

I have made a code that is supposed to start a different program on when you input what day of the week it is, but it doesn't run them when I want them too, Please may someone help me?
The code is this:

@echo off
cd RosaryMysteries
title Rosary
color 1e
:start
echo The Rosary
echo.
pause

goto choice

REM joyful
:joyful
start joyful.bat
exit

REM sorrowful
:sorrowful
start sorrowful.bat
exit

REM luminous
:luminous
start luminous.bat
exit

REM glorious
:glorious
start glorious.bat
exit

REM choice
:choice
cls
set /p day = What is the day of the week today? (No caps please)
if /i {%day%}=={monday} then goto :joyful
if /i {%day%}=={tuesday} then goto :sorrowful
if /i {%day%}=={wednesday} then goto :glorious
if /i {%day%}=={thursday} then goto :luminous
if /i {%day%}=={friday} then goto :sorrowful
if /i {%day%}=={saturday} then goto :joyful
if /i {%day%}=={sunday} then goto :glorious


Jump to Best Answer ↓   Report •


#1
Vote Down
Score
0
Vote Up
February 10, 2012 at 03:06:30 Pacific

Best Answer

Replace (the same for each IF statement)

if /i {%day%}=={monday} then goto :joyful

with

if /I "%day%"=="monday" goto :joyful

and avoid spaces around = in SET statements, i.e.

set /P day=What is the day of the week today? (No caps please)^>

By the way the /I switch of IF statement forces to ignore upper/lower case. More to launch the selected batch and exit just code, e.g.

joyful

not

start joyful.bat
exit

The above leads to a straightforward code as

if /I "%day%"=="monday" joyful

I can send you a little program to autodetect the day of the week without prompting the user. If interested contact me by a private message reporting your e-mail address.

Reply ↓  Report •

#2
Vote Down
Score
0
Vote Up
February 11, 2012 at 06:42:09 Pacific

Thanks! :-)

Reply ↓  Report •

Reply to Message Icon Start New Discussion
Related Posts

« [Solved] Text files read in direct... vb script connect to linu... »