command line parsing question

#1
Hallo,
in a batch file I wanted to show some messages and found a strange behaviour in the output of an echo command. This echo command
echo At %_TIME: T=%_TRANSIENT
displayed
At 14:55:39_TRANSIENT
Without the colon after %_TIME I got the expected
At 14:57:38 T=0

What does the colon do in the echo?
BTW, entering a blank before : does also cure the effect.

This happens with TCC 15.00.33

- Heinz Saathoff
 
May 20, 2009
225
1
53
ITALY
#2
Hallo,
in a batch file I wanted to show some messages and found a strange behaviour in the output of an echo command. This echo command
echo At %_TIME: T=%_TRANSIENT
displayed
At 14:55:39_TRANSIENT
Without the colon after %_TIME I got the expected
At 14:57:38 T=0

What does the colon do in the echo?
BTW, entering a blank before : does also cure the effect.

This happens with TCC 15.00.33

- Heinz Saathoff
I believe that You hit the syntax for text replacement.
At http://ss64.com/nt/syntax-replace.html You can find more information.

Regards

Rodolfo Giovanninetti
 

samintz

Scott Mintz
May 20, 2008
1,241
11
Solon, OH, USA
#3
Yes. That is CMD.EXE's syntax for string substitution. You can work around it in TCC by enclosing the variable in []'s:
Code:
echo %[_TIME]: T=%_TRANSIENT