Welcome!

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

SignUp Now!

Works with CMD.EXE, no output with TCC.EXE

Aug
1,929
71
The following .CMD works properly when run from CMD.EXE, and output is displayed;
Code:
@setlocal
@echo off
ver
setlocal enabledelayedexpansion
for /f "tokens=*" %%A in ('type "owing.txt"') do (
  set /a N += 1
  set "Line!N!=%%A"
)

for /l %%i in (1 1 %N%) do echo !Line%%i!

endlocal

You can substitute "owing.txt" with a text file of your choosing.

When I run this from TCC, no output is displayed.

When I run this from CMDebug v22.00.42 x64 with Options -> CMD Syntax, it runs, but no output is displayed.

Joe
 
Quoting CMD's FOR /?:
Code:
FOR /L %variable IN (start,step,end) DO command [command-parameters]

That is, with commas. When I add commas (and enable !delayed! expansion) it works fine in TCC.
Code:
for /l %%i in (1,1,%N%) do echo !Line%%i!
 
Looks like this is another one of those "it's CMD compatible as long as you make it TCC compatible".

The Microsoft syntax agrees that the for /l commas must also be used, but CMD.EXE still allows proper execution without the commas.

Joe
 
Looks like this is another one of those "it's CMD compatible as long as you make it TCC compatible".

I think it's more "TCC is CMD compatible, but CMD isn't CMD compatible".

I am curious how you came up with that (invalid in everything) syntax - did you find it in a third-party batch file, or did you type random input until CMD didn't actually blow up?
 
I came across Batch files - FOR loops which did not use commas to separate start stop end.

It works in CMD.EXE, regardless that it does not adhere to the Microsoft syntax.

Yes, I do use commas, but I wanted to see how it works with FOR /L in TCC.

It does not.

Joe
 
Yes, I realize that there are no FOR /L examples on that page.

I just wanted to see if a FOR /L works without commas. This works in CMD;
Code:
for /l %i in (1 1 10) do echo %i
but it does not work in TCC.

Joe
 

Similar threads

Replies
0
Views
1K
Back
Top