I worked to delete a cache variable by using @ECHO OFF, but the variable value remain the same after pressing the RETURN key. the variable or cache value is not flushed out.
BATCH PROGRAMMING
A bit more details would be helpful.
@ECHO OFF will not flush anything, it only suppresses echo output of every batch line to the screen.The original poster should always write the last response !!!
Let us know, if the problem is solved !!!
Well there are multiple batch files in a choice statements, when I call a value 2, it stores a '2' value in a buffer. After pressing return key, it always moves to 2 option. So I need to clear the cache after every option.
choice stores the input in the system variable errorlevel.
You can check that with echo %errorlevel% and only stores the position of the valid input.
E.g.:
choise /c 1239
will give
input 1 - errorlevel 1
input 2 - errorlevel 2
input 3 - errorlevel 3
input 9 - errorlevel 4Anyway, you can store this input in your own variable like:
@echo off :start set param=0 cls echo Main Menu echo. echo 1 - Test 1 echo 2 - Test 2 echo 3 - Test 3 echo 9 - End Program choice /c 1239 set param=%errorlevel% if %param% 3 goto stop if %param% 3 call batch3 if %param% 2 call batch2 if %param% 1 call batch1 goto start :stop echo Program stopped.In this case, your own variable param will always be set to 0, when back in main batch file.
The original poster should always write the last response !!!
Let us know, if the problem is solved !!!
It is not working, it gets teminated while opening a batch
@echo off
:start
set param=0
cls
echo Main Menu
echo.
echo 1 - Test 1
echo 2 - Test 2
echo 3 - Test 3
echo 9 - End Program
choice /c 1234set param=%errorlevel%
if %param% 4 goto stop
if %param% 3 goto hi
if %param% 2 goto his
if %param% 1 goto her
goto start:stop
echo Program stopped.
:hi
echo Hi
goto start:his
echo hello
goto start:her
echo bye
goto start
It's not able to start the batch file, automatically terminate out.
thanks done, Thankyou man
You are welcome. The original poster should always write the last response !!!
Let us know, if the problem is solved !!!