Welcome!

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

SignUp Now!

Set 1% then Echo 1%

in CMD.exe

set T=1%
Echo %T%

echos 1%

same in TCC echos only a 1 , not 1%
What is going on?

If you want a literal percent sign, you need to double it:

Code:
set T=1%%
echo %T%

Otherwise, it's interpreted as the start of a variable or function name.
 
Charles Dye wrote:
| Quote:
| Originally Posted by TonyT
| in CMD.exe
|
| set T=1%
| Echo %T%
|
| echos 1%
|
| same in TCC echos only a 1 , not 1%
| What is going on?
|
| If you want a literal percent sign, you need to double it:
|
|
| Code:
| set T=1%%
| echo %T%Otherwise, it's interpreted as the start of a variable or
| function name.

Rex:
Could the parser be enhanced to recognize that a single percent sign % which
is not the terminator of a variable name and which is followed by
"whitespace" (including EOL) could not be the start of a variable name nor
function name, and thus it ought to be used literally?
--
Steve
 
Could the parser be enhanced to recognize that a single percent sign % which is not the terminator of a variable name and which is followed by
"whitespace" (including EOL) could not be the start of a variable name nor
function name, and thus it ought to be used literally?

Probably, though it seems like an extremely uncommon edge condition.
 
rconn wrote:
| Quote:
| Originally Posted by Steve Fabian
| Could the parser be enhanced to recognize that a single percent
| sign % which is not the terminator of a variable name and which
| is followed by "whitespace" (including EOL) could not be the
| start of a variable name nor function name, and thus it ought to be
| used literally?
|
| Probably, though it seems like an extremely uncommon edge condition.

It is, but it would remove a difference from CMD. It would not benefit me
significantly, I have learned to live with current operation.
--
Steve
 
rconn wrote:
| Quote:
| Originally Posted by Steve Fabian
| It is, but it would remove a difference from CMD. It would not
| benefit me significantly, I have learned to live with current
| operation.
|
| ?? Aren't you the same guy who's always railing against CMD
| compatibility??

Sure I am - when it makes coding for TCC more complicated, esp. when
imitating a change in CMD is not backward compatible. OTOH on the extremely
rare occasion when CMD has a good idea which could be adopted into CMD
without breaking backward compatibility I am all for it. Of course, this
specific case would not make TCC coding easier sufficiently that I would ask
for it for my sake.
--
Steve
 
| If you want a literal percent sign, you need to double it:

Code:
set T=1%%
echo %T%

| Otherwise, it's interpreted as the start of a variable or function name.

Thanks for all for help from everybody that posted. Doubling %'s was the hint I needed and I was able to solve my problem just fine now. This was an illustration to a more complicated @EcecStr[] problem I was having and I just kept inserting %'s trial and error until it worked ... 8 %'s in a row to finally get the single % I wanted.

--
Tony
 
Sure I am - when it makes coding for TCC more complicated, esp. when
imitating a change in CMD is not backward compatible.

And this would definitely NOT be backward compatible -- anyone who's doubled their %'s in TCC for this case would now find that their batch files / aliases are mysteriously broken, and would have to track down and edit them.
 
---- Original Message ----
From: rconn
| Quote:
| Originally Posted by Steve Fabian
|| Sure I am - when it makes coding for TCC more complicated, esp. when
|| imitating a change in CMD is not backward compatible.
|
| And this would definitely NOT be backward compatible -- anyone who's
| doubled their %'s in TCC for this case would now find that their
| batch files / aliases are mysteriously broken, and would have to
| track down and edit them.

Ah! You found a valid issue! So this need to go back to the pile of things where CMD malperforms - it does not do what its documentation claims it does - and thus cannot reliably be duplicated. Tongue in cheek suggestion totally withdrawn!
--
Steve
 

Similar threads

Replies
4
Views
2K
Back
Top