Computing.Net > Forums > Programming > Batch File ECHO is off

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.

Batch File ECHO is off

Reply to Message Icon

Name: jcgun
Date: May 18, 2009 at 12:38:49 Pacific
OS: Windows Vista
Subcategory: Batch
Comment:

Hello!!
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
cls
color 0A

:mtrxst2

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

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

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

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

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



Sponsored Link
Ads by Google

Response Number 1
Name: klint
Date: May 19, 2009 at 09:06:06 Pacific
Reply:

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:

echo

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.


0

Response Number 2
Name: Taurus666
Date: May 27, 2009 at 23:35:34 Pacific
Reply:

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


0

Response Number 3
Name: Taurus666
Date: May 27, 2009 at 23:51:05 Pacific
Reply:

and,your example have too much unnecessary code,you can truncate like this:
'================================
@echo off&color 0A&setlocal enabledelayedexpansion
:mtrxst2
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


0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More







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: Batch File ECHO is off

Batch File and Start->Run... www.computing.net/answers/programming/batch-file-and-startrun/8973.html

Batch File To temporarily backup www.computing.net/answers/programming/batch-file-to-temporarily-backup-/9826.html

Batch file help. www.computing.net/answers/programming/batch-file-help/8079.html