Need Bach command

June 18, 2009 at 16:08:20
Specs: Windows XP, Intel core
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.



See More: Need Bach command

Report •


#1
June 18, 2009 at 16:54:02
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


Report •

#2
June 19, 2009 at 05:07:08
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


Report •

#3
July 16, 2009 at 19:10:18
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


Report •

Related Solutions


Ask Question