79Views3Replies

Author Options:

have a question I want batch to do a comand when you use parameters so that when you type in 1 preforms a goto command Answered

so far I hav
@echo off
echo welcome to brian
echo brian will now add 4 1698 times
set/a num=4
:furt
set/a num=%num%+4
echo %num%
if %num%==6792 goto :end
goto :furt
:end
echo you have reached 6792
echo continue?
set v1=goto :count1
set v2=goto :g
echo press 1 to continue
echo press 2 to stop
set/a nu=6792
set/a n=0
set /p you=
if %you%==1 echo %v1%
if %you%==2 echo %v2%

Discussions

0
None
AndyGadget

10 years ago

You need the CHOICE command which was included in DOS from wayyyy back and up until Windows 98. It was then left out of Win2K and XP for some strange reason, but is back again in Vista and Win7.
The linked wikipedia entry gives you the syntax and an example similar to what you want..

0
None
AndyGadgetAndyGadget

Answer 10 years ago

Actually, re-reading your code, you're already using 'set /p'. Doesn't changing the 'echo' to a 'goto' do the trick?

0
None
g-one

10 years ago

@echo off
:: thats the same as yours
echo welcome to brian
echo brian will now add 4 1698 times
set/a num=4
:furt
set/a num=%num%+4
echo %num%
if %num%==6792 goto :end
goto :furt
:end
echo you have reached 6792
echo continue?
set v1=goto :count1
set v2=goto :g
echo press 1 to continue
echo press 2 to stop
set/a nu=6792
set/a n=0
set /p you=
:: here I've changed the code
if "%you%"=="1" %v1%
if "%you%"=="2" %v2%
goto :eof
:count1
echo this is count1
pause
goto :eof
:g
echo this is g
pause

Replace the echo commands under :count1 and :g with your own.