Problem with peculiar CMD syntax

May 20, 2008
603
0
Sammamish, WA
TCC 9.02.152 Windows XP [Version 5.1.2600]
TCC Build 152 Windows XP Build 2600 Service Pack 3

I have two questions:

1) Should environment variable substitution work, with the leading *?

This batch file shows two very different results in 4NT and CMD:
SET FOO=ABCDEFGHI
ECHO %FOO:*DEF=%

4NT:
"environment.htm" last edited 5/8/2008 says:
For compatibility with some peculiar syntax introduced in recent
CMD.EXE versions, TCC supports:
%var:string1=string2% -- Substitutes the second string for all
instances of the first string in the variable.

In CMD, SET /? shows:
%PATH:str1=str2% ... "str1" can begin with an asterisk, in which case
it will match everything from the beginning of the expanded output to
the first occurrence of the remaining portion of str1.


2) What I actually want to solve:

Our development tree for one project is always in some folder, with these extras

(some drive and folder)\KESTREL\X86
(some drive and folder)\KESTREL\COMMON
(some drive and folder)\KESTREL\MICROASM
etc.

We have a standard MAKE batch file that takes one subfolder as an
argument, e.g. MAKE X86, to build that subfolder. I was hoping to
allow it to translate, say a dot "." into "the current folder" so I
could CD to X86 and say "MAKE ." which would then figure out the
current folder and behave as if I had typed "MAKE X86"

I tried using %CD:*KESTREL\=% syntax which works great in CMD but not 4NT. Sigh.

Is there a single compatible line that will work in both?
Unfortunately, we are required to have it work in both shells.

--
2008 Fridays: 4/4, 6/6, 8/8, 10/10, 12/12 and 5/9, 9/5, 7/11, 11/7.
Next year they're Saturday.
Measure wealth by the things you have for which you would not take money.
 

samintz

Scott Mintz
May 20, 2008
1,514
18
Solon, OH, USA
You could try this:

if %@EVAL[1+1] == 2 (
set Proj=%@name[%_CWD]
) else (
set Proj=%CD:*KESTREL\=%
)

-Scott

"JP Software Forums" <neil@jpsoft.com> wrote on 10/02/2008 04:20:50 PM:


> TCC 9.02.152 Windows XP [Version 5.1.2600]
> TCC Build 152 Windows XP Build 2600 Service Pack 3
>
> I have two questions:
>
> 1) Should environment variable substitution work, with the leading *?
>
> This batch file shows two very different results in 4NT and CMD:
> SET FOO=ABCDEFGHI
> ECHO %FOO:*DEF=%
>
> 4NT:
> "environment.htm" last edited 5/8/2008 says:
> For compatibility with some peculiar syntax introduced in recent
> CMD.EXE versions, TCC supports:
> %var:string1=string2% -- Substitutes the second string for all
> instances of the first string in the variable.
>
> In CMD, SET /? shows:
> %PATH:str1=str2% ... "str1" can begin with an asterisk, in which case
> it will match everything from the beginning of the expanded output to
> the first occurrence of the remaining portion of str1.
>
>
> 2) What I actually want to solve:
>
> Our development tree for one project is always in some folder, with
> these extras
>
> (some drive and folder)\KESTREL\X86
> (some drive and folder)\KESTREL\COMMON
> (some drive and folder)\KESTREL\MICROASM
> etc.
>
> We have a standard MAKE batch file that takes one subfolder as an
> argument, e.g. MAKE X86, to build that subfolder. I was hoping to
> allow it to translate, say a dot "." into "the current folder" so I
> could CD to X86 and say "MAKE ." which would then figure out the
> current folder and behave as if I had typed "MAKE X86"
>
> I tried using %CD:*KESTREL\=% syntax which works great in CMD but
> not 4NT. Sigh.
>
> Is there a single compatible line that will work in both?
> Unfortunately, we are required to have it work in both shells.
>
> --
> 2008 Fridays: 4/4, 6/6, 8/8, 10/10, 12/12 and 5/9, 9/5, 7/11, 11/7.
> Next year they're Saturday.
> Measure wealth by the things you have for which you would not take
money.
 
May 20, 2008
603
0
Sammamish, WA
> if %@EVAL[1+1] == 2 (
> set Proj=%@name[%_CWD]
> ) else (
> set Proj=%CD:*KESTREL\=%
> )
> -Scott

I'm currently testing %_4VER for empty in two lines of code -- much
the same. I was hoping for just one syntax that was the same in each,
instead of selecting the different syntaxes.

I was using %@WORD, and like your suggestion of @NAME much better.
Don't know why I didn't think of that.


--
2008 Fridays: 4/4, 6/6, 8/8, 10/10, 12/12 and 5/9, 9/5, 7/11, 11/7.
Next year they're Saturday.
Measure wealth by the things you have for which you would not take money.
 
Similar threads
Thread starter Title Forum Replies Date
old coot Problem with INS key flag in the debugger status bar Support 3
Dick Johnson Weird Color Problem Support 10
fishman@panix.com Problem with 27.15 Support 2
M Problem with VSDevCmd.bat in VS 16.7.3 Support 0
R Problem with @INT[ value] in V26 Support 9
M Selecting test "off by one" problem in Take command Support 4
Alpengreis UTF-8 problem in TCC related to Python Support 7
K_Meinhard Small problem in german IDE 26 Support 3
B Problem with color in nested shells Support 1
Joe Caverly Problem creating and switching to a DESKTOP Support 9
vefatica Another popup problem Support 10
Alpengreis ffind dialog (/W) problem Support 4
Alpengreis [TCMD v25.00.24] Small space problem with the DE translation in Prefs-GUI Support 1
Alpengreis [TCMD v25.00.24] Problem with copy and paste and the # char via mouse in TCC Support 6
A Problem with functions @int @decimal and identifying Powershell as a shell. Support 12
B IF command problem in tcexit.btm Support 9
fishman@panix.com Problem at Startup of TCC Support 3
P Problem with SFTP copies Support 7
P Problem with FTP copies Support 10
Jay Sage Problem with Context Menu Copy+Paste+Run Key Assignment Support 7
R Problem with %_do_loop in nested do loops Support 2
fishman@panix.com New Problem with later Windows 10 Support 10
Peter Murschall A little problem with LEAVE and COMMENT Support 5
M Handling of %~I problem Support 4
WinLanEm FOR problem Support 18
K Problem With SCRPUT /u Support 3
vefatica What's TCMD's problem with ^e[0m? Support 13
Peter Murschall IDE: RTL with non-English resources-problem is back in Build 28 Support 4
rps Regex problem: \xnn not recognized as a hex character Support 0
rps PRIORITY LOW problem Support 1
old coot Regex problem: \xnn not recognized as a hex character Support 12
vefatica Another problem with build 22. Support 3
Alpengreis [23.x] Download-Problem Support 2
S Problem with " Support 3
C Problem navigating forums Support 11
x13 Problem listing repository files using DIR http(s)://... Support 8
Joe Caverly Problem with TEE in v22 Support 2
Alpengreis Problem with thousands delimiter and colors Support 17
M Take Command 18, migrating to another machine, license problem. Support 1
B TCC 21.01.50 Problem with ALIAS /r and SET /r Support 2
rps How to? @search problem Support 2
WinLanEm @SELECT problem Support 6
T Fixed Problem with use of Batch parameters in the IDE Support 1
Oz Solomon Problem with "list" Support 14
S V21.24 theme problem Support 2
Alpengreis Problem if command prompt is not legacy Support 4
Alpengreis TCMD.INI: The "super hidden" problem ... Support 6
G Odd problem - screen brightness Support 4
rps V20 In-process pipes problem Support 8
Alpengreis Again theme problem [v20.0.21]? Support 11

Similar threads