[comp.sys.ibm.pc] DOS command in batch file does not work when "echo off"

deba@mimsy.UUCP (03/14/87)

PROMPT command does not work when "ECHO OFF'" but works when
"ECHO ON". These are the lines in the batch file.

ECHO OFF
IF %1 == RED PROMPT $e[41m
IF %1 == GREEN PROMPT $e[42m

If you have a CGA card try it with echo on and off. If you know
the reason why it does not work please let me know. Hope it is
not a bug in 3.1 DOS.

stevenj@umbc3.UUCP (03/14/87)

In article <5792@mimsy.UUCP> deba@mimsy.UUCP (Deba Patnaik) writes:
>PROMPT command does not work when "ECHO OFF'" but works when
>"ECHO ON". These are the lines in the batch file.
>
>ECHO OFF
>IF %1 == RED PROMPT $e[41m
>IF %1 == GREEN PROMPT $e[42m
>
>If you have a CGA card try it with echo on and off. If you know
>the reason why it does not work please let me know. Hope it is
>not a bug in 3.1 DOS.

No, not a bug in DOS at all.  The above commands will utilize ANSI.SYS 
to change screen colors.  ANSI.SYS, being a video driver (correct term?)
can only get it's commands from things being displayed to the screen, 
in your case, an <ESC>, a right bracket, etc.  (DOS translates the $e to
an <ESC> character).  When you turn ECHO OFF, the command is not displayed to 
the screen, hence ANSI.SYS never sees it, causing the seeming bug.

a workaround:  put the commands in a file and then TYPE the file.  by 
commands, I mean an <ESC>, right bracket etc.  (you'll have to find a
text editor that'll let you put the <ESC> character in the file - SideKick
will for example, I think it's ^P then <ESC>, but check the manual to be
sure).  If you do it right, you'll never see anything but the screen color 
change.  your .BAT file would then look like..

if %1 == RED type REDFILE
if %1 == GREEN type GREENFILE
...

hope this helps.

Steven J Vore
stevenj@umbc3.umd.edu
------------------------------------------------------------------------

bobmon@iuvax.UUCP (03/17/87)

deba@mimsy.UUCP (Deba Patnaik) writes:
>PROMPT command does not work when "ECHO OFF'" but works when
>"ECHO ON". These are the lines in the batch file.
>
>ECHO OFF
>IF %1 == RED PROMPT $e[41m
>IF %1 == GREEN PROMPT $e[42m
> [...]

I'm using (Zenith's release of) MSDOS v3.1, with (Zenith's version of) a CGA
card.  I do just this in my AUTOEXEC.BAT file; the very first line is "echo
off" and a subsequent line defines a fairly long and involved prompt (33 char's
that set up four different colors...).  It works fine for me.  The differences
that I can see between my .BAT file and the example are that my "prompt..."
command is on a line by itself rather than being the end of an "if" statement,
and I have some other "echo..." commands between the initial "echo off" and
the "prompt..." (intermediate colors, etc.).

Which sort of brings me to my question/request.  A while ago there was much
posting about patches to make "echo off" the default.  I saw patches specifying
at least two different locations.  Unfortunately, _my_ MSDOS didn't have the
indicated original value in *either* location, so I haven't made the patch.
So, does anyone have an "echo off" patch that will work with Zenith's MSDOS
v3.1?  Even more important (to me), can anyone supply some context for this
patch?  That is, what are the preceding and following byte values?  Is the
value-to-be-changed in code, or a data table, or what?

~-~-~-~-~
RAMontante (iuvax!bobmon)
Computer Science				"Have you hugged ME today?"
Indiana University

chassin@rpics.RPI.EDU (Dave Chassin) (03/18/87)

In article <3350@iuvax.UUCP>, bobmon@iuvax.UUCP (RAMontante) writes:
> deba@mimsy.UUCP (Deba Patnaik) writes:
> >PROMPT command does not work when "ECHO OFF'" but works when
> >"ECHO ON". These are the lines in the batch file.
> >
> >ECHO OFF
> >IF %1 == RED PROMPT $e[41m
> >IF %1 == GREEN PROMPT $e[42m
> > [...]
> 
> I'm using (Zenith's release of) MSDOS v3.1, with (Zenith's version of) a CGA
> card.  I do just this in my AUTOEXEC.BAT file; the very first line is "echo
> off" and a subsequent line defines a fairly long and involved prompt (33 char's
> that set up four different colors...).  It works fine for me.  The differences
> that I can see between my .BAT file and the example are that my "prompt..."
> command is on a line by itself rather than being the end of an "if" statement,
> and I have some other "echo..." commands between the initial "echo off" and
> the "prompt..." (intermediate colors, etc.).
> 
The important thing to understand is that the PROMPT command does not affect
the screen until the prompt is printed out. This is happens after any one
of the following events (more usual ones, that are others):
	1. ECHO ON is executed AND a command is entered (which will happen)
	2. another batch file is called (either using COMMAND or not)
	   (note that echo will be ON for the new batch file either way,
	    but that if you use COMMAND you can return to you old batch
	    file and echo will still be off, and if you don't use COMMAND
	    you can't returned to the old batch file anyway)
	3. or the batch file ends.
The reason is that the prompt command only sets what the prompt will be
when it is displayed, which doesn't happen then. If I looked at the commands
in your AUTOEXEC file I'm certain that I could show you that the presence
of the IF statement makes no difference, and that it's something else.

Dave

_____________________

David P. Chassin
Rensselaer Polytechnic Institute	              |
School of Architecture			            __+__
Troy, NY   12181			           /  _  \
USA						   | | | |
					  /=======/   =   \=======\
(518) 266-6461				  |   _   |   _   |   _   |
					  |  | |  |  | |  |  | |  |
chassin@csv.rpi.edu			  |   =   |  | |  |   =   |
=======================================================================

ns@maccs.UUCP (Nicholas Solntseff) (03/19/87)

I am also very interested in the details of this patch for ZDS-148s and -158s.

Can anyone help?