- Jul
- 20
- 0
Day 2 of the evaluation - still debugging the debugger - YAB !!!
Here is a sample batch file to demonstrate the very significant difference between TCC and CMD in handling multi-command lines
cls
set var=1&set chr=A
echo Testing& set var=2 & set chr=B & @echo Started %var% %chr%& if %var% GTR 1 echo Still in Test %var% %chr%
@echo test Finished %var% %chr%
When run in Take Command IDE, following is shown on the Debugger screen :-
set var=1
set chr=A
echo Testing
Testing
set var=2
set chr=B
Started 2 B
Still in Test 2 B
test Finished 2 B
And when run in a normal CMD window :-
j:\>set var=1 & set chr=A
j:\>echo Testing & set var=2 & set chr=B &
Testing
Started 1 A
test Finished 2 B
Note that the "Still in Test" echo ONLY happens in TCC !!!
This is because the CMD interpreter uses the variable values at the time before the line is executed, and the whole line is expanded, then executed. Effectively none of the changes to variables are visible until AFTER the line has been executed.
Whilst this functionality of CMD may be considered a "bug" and often causes many lost hours in debugging, I consider it to be a feature.
If the intention is to use the updated values, CMD now has the "delayed variable expansion" option that can be used to force a re-interpretation of a command in the multi-command line
TCC apears to be breaking the multi-command line into multiple single command lines and executing each separately, but with an interesting twist.
The "@" at the front of the "@echo Started %var% %chr%" command suppresses the echo of the command execution.
In CMD, this effects the rest of the multi-command line so display of the "IF command is also suppressed.
Did you spot the twist ?
Yes, even though TCC appears to be processing the multi-command line as single commands, the "@" suppressing the "echo" command has ALSO affected the "IF" command and it's display is suppressed too !!!
Enough for today.
Time to do some real work.
Here is a sample batch file to demonstrate the very significant difference between TCC and CMD in handling multi-command lines
cls
set var=1&set chr=A
echo Testing& set var=2 & set chr=B & @echo Started %var% %chr%& if %var% GTR 1 echo Still in Test %var% %chr%
@echo test Finished %var% %chr%
When run in Take Command IDE, following is shown on the Debugger screen :-
set var=1
set chr=A
echo Testing
Testing
set var=2
set chr=B
Started 2 B
Still in Test 2 B
test Finished 2 B
And when run in a normal CMD window :-
j:\>set var=1 & set chr=A
j:\>echo Testing & set var=2 & set chr=B &
Testing
Started 1 A
test Finished 2 B
Note that the "Still in Test" echo ONLY happens in TCC !!!
This is because the CMD interpreter uses the variable values at the time before the line is executed, and the whole line is expanded, then executed. Effectively none of the changes to variables are visible until AFTER the line has been executed.
Whilst this functionality of CMD may be considered a "bug" and often causes many lost hours in debugging, I consider it to be a feature.
If the intention is to use the updated values, CMD now has the "delayed variable expansion" option that can be used to force a re-interpretation of a command in the multi-command line
TCC apears to be breaking the multi-command line into multiple single command lines and executing each separately, but with an interesting twist.
The "@" at the front of the "@echo Started %var% %chr%" command suppresses the echo of the command execution.
In CMD, this effects the rest of the multi-command line so display of the "IF command is also suppressed.
Did you spot the twist ?
Yes, even though TCC appears to be processing the multi-command line as single commands, the "@" suppressing the "echo" command has ALSO affected the "IF" command and it's display is suppressed too !!!
Enough for today.
Time to do some real work.