Linker IT Software
Google
Web www.oraxcel.com
menubar-top-links menubar-top-rechts
Home Help Search Login
Welcome, Guest. Please Login.
SQL*XL: Database to Excel bridge litLIB: Excel power functions pack ExcelLock: Locking and securing your valuable Excel spreadsheets encOffice: Protect your Excel file easy and safe encOffice: Protect your Excel file easy and safe
Pages: 1
Coding a choice in a batch file (.bat file) (Read 3698 times)
Gerrit-Jan Linker
YaBB Administrator
*****




Posts: 75
Coding a choice in a batch file (.bat file)
12.11.06 at 21:25:22
 
Coding a choice in a batch file (.bat file)
 
To make a choice in a Windows XP batch file the following technique can be used. A set command is used to define an environment variable. set /p prompts for a value. Using if statement the value of the environment variable is checked. Goto is used to jump to the correct code lines.
 
Copy the following text in a plain text file and name the file test.bat:
Code:
set choice=
set /p choice=(1=Option A 2=Option B)

if '%choice%'=='1' goto option_a
if '%choice%'=='2' goto option_b

echo Invalid choice
goto end

:option_a
echo Option A
goto end

:option_b
echo Option B
goto end

:end
 


 
In this code a choice is displayed to enter 1 or 2.
When something else is entered the message: Invalid choice is printed.
When 1 is typed the message: Option A is printed.
When 2 is typed the message: Option B is printed.
Back to top
 
« Last Edit: 12.11.06 at 21:27:37 by Gerrit-Jan Linker »  

Gerrit-Jan Linker
Linker IT Software
Email WWW Gerrit-Jan Linker   IP Logged
Pages: 1