Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Can one Push & Pop the state of echo, and if so how?

32 views
Skip to first unread message

Dr J R Stockton

unread,
Apr 13, 2017, 6:41:18 PM4/13/17
to
Can one Push and Pop the state of Echo, and if so how? I'm interested
in WinXP, Win7, Win10.

--
(c) John Stockton, Surrey, UK. 拯merlyn.demon.co.uk Turnpike v6.05 MIME.
Merlyn Web Site < > - FAQish topics, acronyms, & links.



---
This email has been checked for viruses by AVG.
http://www.avg.com

JJ

unread,
Apr 14, 2017, 1:06:29 AM4/14/17
to
On Thu, 13 Apr 2017 19:51:31 +0100, Dr J R Stockton wrote:
> Can one Push and Pop the state of Echo, and if so how? I'm interested
> in WinXP, Win7, Win10.

You can "push" the ECHO state by putting the code in a separate batch file
and execute that batch file without using the CALL command. If you use the
CALL command to execute the batch file, the ECHO state won't be "pushed"
then "popped".

e.g. AA.CMD:
[code]
@echo off
echo aa start
bb.cmd
echo aa end
[/code]

BB.CMD:
[code]
echo on
echo in bb
[/code]

Execute AA.CMD and it'll output like below.
[code]
E:\TEMP>aa

E:\TEMP>echo in bb
in bb

E:\TEMP>
[/code]

If you use CALL in AA.CMD to execute BB.CMD, it'll output like below.
[code]
E:\TEMP>aa

E:\TEMP>echo in bb
in bb

E:\TEMP>echo aa end
aa end

E:\TEMP>
[/code]

In this context, the SETLOCAL/ENDLOCAL command doesn't matter whether it's
used or not.

Batchman

unread,
Apr 14, 2017, 8:32:56 PM4/14/17
to
Dr J R Stockton wrote:

> Can one Push and Pop the state of Echo, and if so how? I'm
interested
> in WinXP, Win7, Win10.
>
You could simply use this...

set Eco=ON
@echo %Eco%
IF (%Eco%)==(ON)...

In fact you will find that there's lots of cases where assigning a
batch/cmd command to an environment variable can be very useful.


Todd Vargo

unread,
Apr 16, 2017, 11:11:56 PM4/16/17
to
On 4/13/2017 2:51 PM, Dr J R Stockton wrote:
> Can one Push and Pop the state of Echo, and if so how? I'm interested
> in WinXP, Win7, Win10.
>

...
::Store echo state in variable named echostate
for /f "tokens=3" %x in ('echo') do set "echostate=%x"

: change echo state randomly
...

::Restore echo state and clear variable
echo %echostate%
set "echostate="

--
Todd Vargo
(Post questions to group only. Remove "z" to email personal messages)

Robert Roland

unread,
Apr 17, 2017, 7:01:58 AM4/17/17
to
On Sun, 16 Apr 2017 23:11:54 -0400, Todd Vargo
<tlv...@sbcglobal.netz> wrote:

>::Store echo state in variable named echostate
>for /f "tokens=3" %x in ('echo') do set "echostate=%x"

That's exactly what I tried, except I did it in a batch file. I got
"ON" as a result regardless of which state it really was:

C:\test>type test.bat
@echo off
echo
for /F "tokens=3 delims=. " %%n in ('echo') do set savedstate=%%n
echo Echo is currently %savedstate%
echo

C:\test>test.bat
ECHO is off.
Echo is currently on
ECHO is off.

C:\test>
--
RoRo

Dr J R Stockton

unread,
Apr 19, 2017, 6:39:44 PM4/19/17
to
In alt.msdos.batch.nt message <YR8Pxwzz...@invalid.uk.co.demon.merl
yn.invalid>, Thu, 13 Apr 2017 19:51:31, Dr J R Stockton <reply1700@merly
n.demon.co.uk.invalid> posted:

>Can one Push and Pop the state of Echo, and if so how? I'm interested
>in WinXP, Win7, Win10.

Thanks for the various answers, which have interesting parts.

But I was asking for Push and Pop, rather than Save and Restore; and I
was hoping for something built-in, similar to PushD and PopD.

Push & Pop of Echo could be done by extending the offerings to store in
stack form in the Environment; I don't want to go to that trouble.
0 new messages