Computing.Net > Forums > Programming > Need Bach command

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Need Bach command

Reply to Message Icon

Name: omaga99
Date: June 18, 2009 at 16:08:20 Pacific
OS: Windows XP
CPU/Ram: Intel core
Subcategory: Batch
Comment:

I have made a basic calculator in bach using notepad. It works just fine but I would like to add a function so I can use it for a larger variety of functions. The code for it is as follows...

@echo off
color 0a
:hom
title Calculator
echo Welcome to OMAGA.inc operation controller. Type a value to proceed.
set/p one=
cls
echo Function type
set/p two=%one%...
echo Secondary value
set/p three=%one%%two%...
set/a final=%one%%two%%three%
cls
echo Output value:
echo %one%%two%%three%=%final%
pause
cls
goto hom


In this code after the line

echo Welcome to OMAGA.inc operation controller. Type a value to proceed.

I would like a function when if you were to type something like "Database" the program will jump to somewhere else in the code and exicute it. As to going to the next line in the code.




Sponsored Link
Ads by Google

Response Number 1
Name: RobJohnB95
Date: June 18, 2009 at 16:54:02 Pacific
Reply:

if you were to type something like "Database" the program will jump to somewhere else in the code and exicute it

set /p database=
if %database% == database goto Database
if %database% == Database goto Database
:Database
echo you must hav typed database or Database to read this
pause>nul
exit


0

Response Number 2
Name: lee123abc
Date: June 19, 2009 at 05:07:08 Pacific
Reply:

I have this, but it crashes if you press enter at the database part. If you just type a random digit to continue it works though.

@echo off & color 0a
:hom
title Calculator
echo Welcome to OMAGA.inc operation controller. Type a value to proceed.
set /p database=
if /i %database% == database call :Database
goto :continue
:Database
echo you must hav typed database or Database to read this
pause>nul & goto :EOF
:continue
set/p one=
cls & echo Function type
set/p two=%one%...
echo Secondary value
set/p three=%one%%two%...
set/a final=%one%%two%%three%
cls & echo Output value:
echo %one%%two%%three%=%final%
pause
cls & goto :hom


0

Response Number 3
Name: screwed124816
Date: July 16, 2009 at 19:10:18 Pacific
Reply:

try this

@echo off
color 0
title Calculator
:hom
cls
echo Welcome to OMAGA.inc operation controller. Type a
value to proceed.
set/p one=
if /i "%one%"=="database" goto hom
cls
echo Function type
set/p two=%one%...
if /i "%two%"=="database" goto hom
echo Secondary value
set/p three=%one%%two%...
if /i "%three%"=="database" goto hom
set/a final=%one%%two%%three%
cls
echo Output value:
echo %one%%two%%three%=%final%
pause
cls
goto hom


0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More


Batch file to find ip and... can we can java program f...



Post Locked

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


Go to Programming Forum Home


Sponsored links

Ads by Google


Results for: Need Bach command

VB6 Command Need Help www.computing.net/answers/programming/vb6-command-need-help/13758.html

ASCII Commands for Serial port www.computing.net/answers/programming/ascii-commands-for-serial-port/7499.html

format command for my version ofDOS www.computing.net/answers/programming/format-command-for-my-version-ofdos/10787.html