3a451fbd93eb17f84f06c7ac648bdcab

I need to create this program for class. I'm not looking for the answer. I'm simply confused on how to create a batch file where I input a number and it gives me an option. Would I use the IF command if so how would I do it. My teacher is awful and he doesn't explain anything.

Here is what I got so far

@ECHO OFF
ECHO This BAT file will display the symbol of your choice
Echo.
ECHO 1. Stars
ECHO 2. Dollars
ECHO 3. Pluses
ECHO e. Exit Program
ECHO.
ECHO Enter your choice (1, 2, 3, e)
IF 

PAUSE

Recommended Answers

All 9 Replies

I inputted this, but there was still an error. Any advice.

@ECHO OFF

ECHO This BAT file will display the symbol of your choice
Echo.
ECHO 1. Stars
ECHO 2. Dollars
ECHO 3. Pluses
ECHO e. Exit Program
ECHO.

REM Setting the Variables
ECHO 1. **********
ECHO 2. $$$$$$$$$$
ECHO 3. ++++++++++
ECHO e. :exit
SET /P Choice = Enter your choice (1,2,3,e)
ECHO Enter your choice (1, 2, 3, e)



PAUSE

You definately want some GOTOs in there
here's mine, idk why it wont work I think i just need to figure out how to set variables based on input DURING the program

REM symbols.bat
REM CREATED BY Brooks Johnson
@ECHO OFF

:beginning
ECHO This BAT file will display the symbol of your choice
ECHO.
ECHO 1. Stars
ECHO 2. Dollars
ECHO 3. Plusses
ECHO e. Exit Program
ECHO.
SET /P Choice=Enter your choice

IF [Choice] == [e] GOTO exit
IF [Choice] == [1] GOTO choiceone
IF [Choice] == [2] GOTO choicetwo
IF [Choice] == [3] GOTO choicethree
GOTO errorscreen

:choiceone
ECHO **********
GOTO exit

:choicetwo
ECHO $$$$$$$$$$
GOTO exit

:choicethree
ECHO ++++++++++
GOTO exit

:errorscreen
ECHO I am become error :'(
rem GOTO beginning

:exit
pause

If you want to show what a variable is, you can put
ECHO %variable%

heres the finished version
we had to use brackets AND %s in the if statments, and ALSO use GOTOs

REM symbols.bat
REM CREATED BY Brooks Johnson
@ECHO OFF

:beginning
ECHO This BAT file will display the symbol of your choice
ECHO.
ECHO 1. Stars
ECHO 2. Dollars
ECHO 3. Plusses
ECHO e. Exit Program
ECHO.
SET /P Vary=Enter input

IF [%Vary%] == [e] GOTO exit
IF [%Vary%] == [1] GOTO choiceone
IF [%Vary%] == [2] GOTO choicetwo
IF [%Vary%] == [3] GOTO choicethree
ECHO %Vary%
GOTO errorscreen

:choiceone
ECHO **********
GOTO exit

:choicetwo
ECHO $$$$$$$$$$
GOTO exit

:choicethree
ECHO ++++++++++
GOTO exit

:errorscreen
ECHO I am become error :'(
rem GOTO beginning

:exit
pause

I believe the file has to repeat without shutting off Brooks.

This is what I got it repeats but it won't select the right option. It just gives me stars.

@ECHO OFF
ECHO This BAT file will display the symbol of your choice
Echo.
:beginning
ECHO.
ECHO 1. Stars
ECHO 2. Dollar
ECHO 3. Pluses
ECHO e. Exit Program
ECHO.
SET /P Choice = Enter your choice (1, 2, 3, e)
ECHO.

IF [Choice] == [1] GOTO one
IF [Choice] == [2] GOTO two
IF [Choice] == [3] GOTO three
IF [Choice] == [e] GOTO exit

:one
ECHO **********
GOTO beginning
ECHO.

:two
ECHO $$$$$$$$$$
GOTO beginning
ECHO.

:three
ECHO ++++++++++
GOTO beginning
ECHO.

:exit
PAUSE


PAUSE

you gotta do
IF [%Choice%] == whatever
with the percent things

commented: Thanks a lot +1

It only displays option one

REM symbols.bat
REM Created by Ashraf Shawwa
@ECHO OFF
:beginning
ECHO This BAT file will display the symbol of your choice
Echo.
ECHO.
ECHO 1. Stars
ECHO 2. Dollar
ECHO 3. Pluses
ECHO e. Exit Program
ECHO.
SET /P Choice = Enter your choice (1, 2, 3, e) 
ECHO.

IF [%Choice%] == [1] GOTO one
IF [%Choice%] == [2] GOTO two
IF [%Choice%] == [3] GOTO three
IF [%Choice%] == [e] GOTO exit



:one
ECHO **********
GOTO beginning
ECHO.

:two
ECHO $$$$$$$$$$
GOTO beginning
ECHO.

:three
ECHO ++++++++++
GOTO beginning
ECHO.

:exit
PAUSE


PAUSE

Figured it out, there has to be no space between equal and words SET /P Choice = Enter your choice (1, 2, 3, e)

it says it's in the wrong format, i can't post any shell script

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.