Computing.Net > Forums > Disk Operating System > Batch file menu Problems

Computing.Net: Over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to sign up now, it's free!

Batch file menu Problems

Reply to Message Icon

Original Message
Name: Fro
Date: October 19, 2003 at 09:20:09 Pacific
Subject: Batch file menu Problems
OS: Win XP pro
CPU/Ram: 1.39/512mb
Comment:

Hello,i,m currently working on a batch file with a menu and i am having a few problems this is what i have done so far,

@ECHO OFF

:MENU
CLS
ECHO 1. Display Time
ECHO 2. Display Date
ECHO 3. Display Current Directory
ECHO Q to Quit

set INPUT=
set /p INPUT Please make a selection

if "%input%"==""goto MENU
if %input% == 1 goto TIME
if %input% == 2 goto DATE
if %input% == 3 goto DIR
if %input% == Q goto QUIT

:TIME
TIME
goto MENU

:DATE
DATE
goto MENU

:DIR
DIR
goto MENU

:QUIT
echo.
echo Goodbye
echo.
echo.
pause
exit

When i try to use the program it says "The syntax of the command is incorrect, goto was unexpected at this time"

I have tried the CHOICE command but it does not work as my version of MS-DOS (5.1) does not have that command implemented yet.

Can you see where i might have gone wrong with the code, or if i,m doing something incorrect.

Thankyou for any help


Report Offensive Message For Removal


Response Number 1
Name: IVO
Date: October 20, 2003 at 02:46:30 Pacific
Reply: (edit)

The statement
Set /P INPUT Please make a selection
should be
Set /P INPUT=Please make a selection
(insert a = after INPUT without spaces)
The statement
If "%input%"==""goto MENU
should be
If "%input%"=="" goto MENU
(insert a space between "" and goto)
The statement
If %input% == 1 goto TIME
(and the other three 2, 3, Q)
shoulde be
If "%input%"=="1" goto TIME
(no spaces in front and after the ==)
Quotes are not mandatory, but I prefer to express them.
The statement
If "%input%"=="Q" goto QUIT
should be
If /I "%input%"=="Q" goto QUIT
otherwise you can not trap the q selection that will lead to TIME.

By the way, Choice is not included in the standard XP Home and Pro versions of Windows that has no DOS at all. What you see at the command prompt is an emulated text interface resembling DOS, but really managed by a Virtual DOS Machine (NTVDM).


Report Offensive Follow Up For Removal

Response Number 2
Name: IVO
Date: October 20, 2003 at 02:54:33 Pacific
Reply: (edit)

And more, insert
GoTo MENU
after
If /I "%input%"=="Q" goto QUIT
to trap each choice not in the range you planned to manage.


Report Offensive Follow Up For Removal







Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Disk Operating System Forum Home








Do you have a Desktop Computer anymore?

No
Yes, but only at work
Yes, but its rarely used
Yes, and its a workhorse


View Results

Poll Finishes Today.
Discuss in The Lounge
Poll History




Data Recovery Software