Welcome!

By registering with us, you'll be able to discuss, share and private message with other members of our community.

SignUp Now!

The BatchEcho option

Apr
318
7
... sets the default value for 1 of 2 echo settings, namely the one determining echoing during batch execution. At least that is what I gather from our Help.

option //BatchEcho=No should, according to the same Help, "take effect immediately, and be in effect for the current session."

Whereas in my TCStart it has no effect.

SETDOS /V0 has also does not suppress default echoing.

Only ECHO OFF does what I expect it to do.

I am confused.
 
It works correctly for me. My TCMD.INI has BatchEcho=No, so that is my default.
Code:
[C:\test] echo echo >foo.btm

[C:\test] foo
ECHO is OFF

[C:\test] setdos /v1

[C:\test] foo
echo
ECHO is ON

[C:\test] setdos /v0

[C:\test] option //BatchEcho=Yes

[C:\test] foo
echo
ECHO is ON

[C:\test] option //BatchEcho=No

[C:\test] foo
ECHO is OFF
 
Thank you for your reply, Scott.

Here is a quote from the manual that took me by surprise: "TCC controls command line echoing in batch files and at the interactive prompt independently". So, ECHO ON/OFF on the command line control one piece of state, and the same commands in a running batch control another. I did not know that, until I read it today! So what you just demonstrated is how to toggle 1 of the 2 state variables. I'm sorry to say that my question is about the other one, the "running batch" one, and also that it is not about the ECHO command, as that seems to works as expected on my side too.

It's the option //BatchEcho=No, where the default is Yes, that seems to be ignored. I.e. the batch starts with echo on and keeps echoing even though I use the aforementioned option command.

So, weird or what?

Regards, DJ.
 
If the default is BatchEcho=Yes, and you say "OPTION //BatchEcho=No", that affects only the current instance. Any subshells (transient, pipe, ...) a batch file may start will read the INI file and have BatchEcho=Yes and you'll see (if nothing else) what's in TCStart.btm. I'm not sure it's ideal, but that seems to be how it is.

Did you know that if you prefix a command in a batch file (notably TCStart.btm) with "@" it won't be echoed (regardless of the BatchEcho setting). Unless you're keenly interested in having TCStart echo its commands, use "@ECHO OFF" as it's first line.
 
If the default is BatchEcho=Yes, and you say "OPTION //BatchEcho=No", that affects only the current instance.

The point is: it does not.

Code:
@iff "%@option[BatchEcho]" eq "No" then
    @echo Go ahead and switch BatchEcho=Yes, as that is the default, and restart.
    @quit 0
@else
    @echo So, we start with echoing ON.
    @echo Now, let's turn it off,..
    option //BatchEcho=No
@endiff
@echo.
echo ... then you should see these lines only once!

It is probably so simple that nobody bothers to really test it?
I don't care which it is, but either the docs are wrong or ...
 
What am I supposed to see? I put your code into my TCStart.btm and used the OPTION dialog to check DefaultBatchEcho (made it Yes). Then I started a new TCC. As expected, I saw:
Code:
So, we start with echoing ON.
Now, let's turn it off,..
option //BatchEcho=No

echo ... then you should see these lines only once!
... then you should see these lines only once!
Now the current instance has BatchEcho=Off.
Then I ran a BTM which starts a transient instance (between "HERE1" and "HERE2"). I saw this (as expected). There was no echoing before "HERE1". DefaultBatchEcho was back to Yes in the transient instance.
Code:
v:\> avtemp.btm
19:54  55
18:54  57
17:54  59
16:54  61
15:54  63
14:54  61
13:54  60
12:54  59
11:54  60
10:54  60
09:54  59
08:54  59
07:54  58
06:54  58
05:54  58
04:54  60
03:54  62
02:54  62
01:54  62
00:54  62
23:54  62
22:54  62
21:54  63
20:54  63

Average: 60.21

Predict:  0.41 / 0.13 / 0.27

HERE1!
So, we start with echoing ON.
Now, let's turn it off,..
option //BatchEcho=No

echo ... then you should see these lines only once!
... then you should see these lines only once!
Low:  53
High: 71
Low:  52
High: 79
Low:  58
High: 82
Low:  61
High: 83
Low:  62
HERE2!

Notice that I don't see "echo HERE1" and echo "HERE2" because BatchEcho is No in the original instance. Here's the code that causes the transient instance to be created.

Code:
echo HERE1!

tpipe /input=h:\temp\forecast.tmp ^
   /grep=3,0,0,1,0,0,0,0,"High: \d\d|Low: \d\d" ^
   /simple=16 ^
   /replace=4,0,0,0,0,0,0,0,0," &",\n ^
   /replace=4,0,0,0,0,1,0,0,0,"High.*$|Low.*$",$0\n ^
   /simple=12 ^
   /replace=0,1,0,1,0,0,0,0,0,"Low: ","Low:  "
   
echo HERE2!
 
P.S. "OPTION //BatchEcho=..." applies to subsequently started batch files. If you want to turn it on/off while already in a batch file, use "ECHO ON/OFF".
 
Thank you guys, for helping me out here,..

P.S. "OPTION //BatchEcho=..." applies to subsequently started batch files.

Under TCC | Commands | Option, section "Setting Individual Options Temporarily" an example is shown that even specifically uses the BackEcho option and says (just above that line) that it will be in effect immediately. No mention of subsequent restarts.

The counter examples you gave me were either in interactive mode or using sub-shells. The first apparently uses a different state variable that shouldn't be influenced by any OPTION setting, only by ECHO <on|off>. The second reread the ini-file which undoes any temporary modifications you might have made in whatever kind of way, thereby not proving anything about the supposed immediacy of the OPTION setting.

So, my conclusion is that the manual is merely misleading in this section.

The OPTION //BatchEcho= command doesn't affect the actual state, it (temporarily) sets the state's default value. The SETDOS /V<0|1> does the exact same thing. Nothing immediate and nothing permanent. If you want permanent, do an %@iniwrite[%_ininame,4NT,BatchEcho,No].

Only the state variables themselves - for there are two - have immediacy. These states are affected only by the an ECHO <on|off> command in respectively batch-mode or interactive-mode. What the internal variable _echo expands to, I will leave as an exercise to the reader.

The fact that there are two echo-states was news to me, even after having written many thousands of lines of code for this - our beloved and amazing - tool.

Anyway, let's get to work on something important. ;-)

Kind regards, DJ.
 

Similar threads

Back
Top