Difference between TCC and CMD: variable names with hyphens

Oct 18, 2009
362
17
In TCC 22, 32-bit a difference between TCC and cmd:

Set DEN_a-temp="Hello"

Echo %DEN_a-temp

TCC: -temp
CMD: %DEN_a-temp ( WAD )

Echo %DEN_a-temp%

TCC: -temp
CMD: "Hello"

In the actual usage the variable name stands for "a file with Insurance Denial records in the temporary-hold folder \a-temp". The folder is named "a-temp" so it will display first in File Manager. The data the variable actually holds is a path ending with a slash.
 
May 20, 2008
11,411
99
Syracuse, NY, USA
Try "OPTION //CmdVariables=Yes".

Code:
v:\> echo %[a-b]
"Hello"

v:\> echo %a-b%
-b

v:\> echo %a-b
-b

v:\> option //cmdvariables=Yes

v:\> echo %[a-b]
"Hello"

v:\> echo %a-b%
"Hello"

v:\> echo %a-b
"Hello"
 

rconn

Administrator
Staff member
May 14, 2008
12,356
150
A '-' is technically not a valid variable name character. CMD doesn't care because it requires leading & trailing %'s to delineate the name. TCC only requires the leading character -- unless you want to use an invalid character. Then, either use %[…] or turn on CMDVariables (which will then require ALL variables to have leading & trailing %'s).
 
Oct 18, 2009
362
17
I found this in the Help, which explains the behavior:

TCC Variables and Functions

"The environment variable names you use this way may contain any alphabetic or numeric characters, the underscore character _, and the dollar sign $. You can force acceptance of other characters by including the full variable name in square brackets, like this: %[AB##2]. You can also indirectly reference environment variables using square brackets. For example %[%var1] means "the contents of the variable whose name is stored in VAR1".
...
The trailing percent sign that was traditionally required for environment variable names is not usually required by TCC, which accept any character that cannot be part of a variable name as the terminator. However, the trailing percent can be used to maintain compatibility with CMD."

--------------------------
When I saw the code wasn't working I realized TCC was probably treating it as math and was trying to subtract temp from DEN_a, but I was surprised that when I added a closing % TCC didn't consider DEN_a-temp to be a variable name.
 
Aug 23, 2010
637
9
I'm using "%[…]" syntax personally to increase compatibility with TCC itself (i.e. reduce any doubt about what is considered variable's name).
 
Similar threads
Thread starter Title Forum Replies Date
T WAD Difference between TCC and CMD in handling multi-command lines Support 6
C Documentation difference between appdata and localappdata ? Support 6
E TCC/CMD difference Support 5
W Starting program for word to pdf conversion (difference cmd and tcc) Support 13
jwiede Difference in "FOR /F" behavior (?) Support 1
R Difference in behavior of RMDIR vs. CMD.EXE? Support 5
Steve Pitts Difference in exection with and without START Support 24
S Inexplicable behavior difference in nearly identical shortcuts Support 6
S TCC 9.02 vs 4NT 8.02 difference - for %a COPY Support 6
D Differences between TCC and CMD with COPY /b Support 4
R Lines between COMMENT & ENDCOMMENT not ignored Support 7
W pdir returns diff results between tcc and tcmd - one is an error msg Support 5
M Command line parsing differences between cmd.exe and TCC Support 6
L WAD bad interaction between echox and command grouping Support 9
D Fixed Change in behavior of variable expansion between 16 and 17 Support 3
Joe Caverly How to? Move Window Between Monitors Support 6
epement differences in IDE/debugger between v12 and v14 Support 1
beerns different results between tcmd and cmd Support 2
C sharing global histories between different TCMD versions? Support 5
Jay Sage Inconsistency in Date Formats Between @DATE and @MAKEDATE Support 3
fpefpe Key Names to toggle between tab windows Support 1
Joe Caverly Move Buttons Between Tabbed Toolbars Support 2
D sync navigation between Folders List panel and the Tabs console Support 11
MickeyF TCC crashing when copying multiple files (now resolved) Support 6
C COMSPEC constantly reset to TCC.EXE Support 6
rconn News Take Command / TCC / CMDebug / TCC-RT v28 Released Support 0
C How to? starting TCC/TCMD v25 Support 2
CWBillow TCC and TCMD in Powershell Support 6
rconn News Take Command / TCC / CMDebug / TCC-RT 27.01.24 uploaded Support 0
rconn News Take Command / TCC / CMDebug / TCC-RT 27.01.23 uploaded Support 0
Alpengreis Fixed Crash after copy dialog with big TCC.exception.log Support 5
rconn News Take Command / TCC / CMDebug / TCC-RT v27.01 Build 22 Uploaded Support 0
L FTYPE in TCC, less quirky than in cmd.exe Support 3
V Set path permanently from within TCC? Support 3
DrusTheAxe Runaway TCC.exception.log filling drive Support 5
rconn News Take Command / TCC / CMDebug / TCC-RT 27.0.21 uploaded Support 0
Joe Caverly tcc.exception.log Support 3
rconn News Take Command / TCC / CMDebug / TCC-RT 27.0.20 uploaded Support 0
rconn News Take Command / TCC / CMDebug / TCC-RT 27.0.19 Support 0
FreezerBurnt Help making a CMD and TCC compatible batch file Support 7
vefatica SCRIPT ... TCC disappears Support 2
rconn News Take Command / TCC / CMDebug / TCC-RT v27.0.18 Support 0
Jesse Heines Access Denied errors in TCC 27 Support 9
fpefpe How to? tcc inifile (%_ininame) Support 3
M How to? Black TCC Prompt Support 2
M Oracle batch OPatch.bat.bat not working in TCC but correctly in CMD Support 5
Jay Sage Extra TCC Tasks Support 6
vefatica Can I turn off the minimize to tray mechanism in TCC? Support 5
N Command execution slows down in TCC Prompt after a while Support 6
R Upgrade TCMD 19 to TCC 26 Support 1

Similar threads