Problem with %var:find=replace% syntax

  • This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.
#1
The syntax %var:find=replace% does not appear to work when the variable is
an internal variable.

TCC 10.00.48 Windows XP [Version 5.1.2600]
TCC Build 48 Windows XP Build 2600 Service Pack 3


D:\test>echo %_cwd
D:\test

D:\test>set zzz=%_cwd

D:\test>echo %_cwd:test=qqqq% %zzz:test=qqqq%
D:\test D:\qqqq

--
Jim Cook
2009 Saturdays: 4/4, 6/6, 8/8, 10/10, 12/12 and 5/9, 9/5, 7/11, 11/7.
Next year they're Sunday.
 
#2
On Thu, Feb 5, 2009 at 8:25 AM, JP Software Forums <neil@jpsoft.com> wrote:


> The syntax %var:find=replace% does not appear to work when the variable is
> an internal variable.
>
> TCC 10.00.48 Windows XP [Version 5.1.2600]
> TCC Build 48 Windows XP Build 2600 Service Pack 3
>
>
> D:\test>echo %_cwd
> D:\test
>
> D:\test>set zzz=%_cwd
>
> D:\test>echo %_cwd:test=qqqq% %zzz:test=qqqq%
> D:\test D:\qqqq
>
It appears _some_ internal variables are not affected, but some are.

D:\test>set zzz=%CD%

D:\test>echo %CD% .. %_CWD% .. %ZZZ%
D:\test .. D:\test .. D:\test

D:\test>echo %CD:test=qqqq% .. %_CWD:test=qqqq% .. %ZZZ:test=qqqq%
D:\qqqq .. D:\test .. D:\qqqq


--
Jim Cook
2009 Saturdays: 4/4, 6/6, 8/8, 10/10, 12/12 and 5/9, 9/5, 7/11, 11/7.
Next year they're Sunday.
 

Charles Dye

Super Moderator
Staff member
May 20, 2008
3,376
39
Albuquerque, NM
prospero.unm.edu
#4
<NEIL@JPSOFT.COM>
It appears _some_ internal variables are not affected, but some are.

D:\test>set zzz=%CD%

D:\test>echo %CD% .. %_CWD% .. %ZZZ%
D:\test .. D:\test .. D:\test

D:\test>echo %CD:test=qqqq% .. %_CWD:test=qqqq% .. %ZZZ:test=qqqq%
D:\qqqq .. D:\test .. D:\qqqq
That makes sense to me. That nasty syntax is only there for compatibility with CMD.EXE, which does not support TC's internal variables -- but does have a few of its own, including CD.

If you're writing for TC, you can and should use @REPLACE instead.

</NEIL@JPSOFT.COM>
 
#5
>
>
> ---Quote---
> >The syntax %var:find=replace% does not appear to work when the variable is
> >an internal variable.
> ---End Quote---
> Did you expect it to work? I wouldn't.
>

Well, yes. That's why I reported it.

Especially since %CD% does work but %_CWD% does not -- I find that very
odd.

--
Jim Cook
2009 Saturdays: 4/4, 6/6, 8/8, 10/10, 12/12 and 5/9, 9/5, 7/11, 11/7.
Next year they're Sunday.