Solved Batch File ECHO is off

May 18, 2009 at 12:38:49
Specs: Windows Vista
At the bottom of this post is my tester for a Matrix Batch File. Problem? It keeps saying 'ECHO is off.'

Don't know how to fix it. need your help.
Please have a look, and suggest a resolution.

@echo off
color 0A


@echo off
set /a mAsp=%random%%%6+1
if '%mAsp%'=='1' goto mtrxmA1
if not '%mAsp%'=='1' goto mtrxmA2
set /a mA=%random%%%9+0
goto mtrxmA3
set mA=

@echo off
set /a mBsp=%random%%%6+1
if '%mBsp%'=='1' goto mtrxmB1
if not '%mBsp%'=='1' goto mtrxmB2
set /a mB=%random%%%9+0
goto mtrxmB3
set mB=

@echo off
set /a mCsp=%random%%%6+1
if '%mCsp%'=='1' goto mtrxmC1
if not '%mCsp%'=='1' goto mtrxmC2
set /a mC=%random%%%9+0
goto mtrxmC3
set mC=

@echo off
set /a mDsp=%random%%%6+1
if '%mDsp%'=='1' goto mtrxmD1
if not '%mDsp%'=='1' goto mtrxmD2
set /a mD=%random%%%9+0
goto mtrxmD3
set mD=

echo %mA% %mB% %mC% %mD%
@echo off
goto mtrxst2

See More: Batch File ECHO is off

Report •

May 19, 2009 at 09:06:06
It's because you've got this line:

echo %mA% %mB% %mC% %mD%

and all the variables translate to an empty string, because none of them have been set. In that case, the command is actually just this:


which means "tell me whether echo is on or off."

You can look through your code and work out the probability that any of these variables will have been set - it's like throwing a dice each time you are about to set a variable and only setting it if you throw a certain number.

Report •

May 27, 2009 at 23:35:34
I'am a Chinese,I'm not good at English...
Because all %m?sp% is empty string, A B C D all jump to :mtrxm?2 very likely in near value series

Fix it code is so easy,just put a drop after "echo" ,like this:
echo. %mA% %mB% %mC% %mD%
this drop can hide 'echo is off' to reveal

Report •

May 27, 2009 at 23:51:05
✔ Best Answer
and,your example have too much unnecessary code,you can truncate like this:
@echo off&color 0A&setlocal enabledelayedexpansion
set /a q+=1
set /a ALLsp%q%=!random!%%6+1
if !ALLsp%q%!==1 ( set /a "m%q%"=!random!%%9+0 ) else ( set m%q%= )
if %q%==4 ( set /a q=0 & echo. %m1% %m2% %m3% %m4%)
goto :mtrxst2
after amend,total code can lss than anyone str setting part in original code, just have 4 line of nucleus

Report •

Related Solutions

Ask Question