Welcome!

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

SignUp Now!

Done Add the possibility to comment the ENDIFF

It seems to be convenient to have the possibility to comment the ELSE and ENDIFF on the same line:
iff "%a" == "s1" then
***
iff isdir "%b" then
***
else %b
***
endiff %b
***
else %a
***
iff %c LE 7 then
***
else %c
***
endiff %c
***
endiff %a

The idea is to make the TCC accepting and ignoring the "parameters" of the ELSE and ENDIFF clauses. Now such commenting requires a combination of the 'command separator symbol' with the REM command, which seems ugly and increases the file's size.
 
Last edited:
Apparently you can do that with just "::". This seems to work OK.

Code:
iff "%1" == "1" then :: beginning of IFF
    echo OK
else :: "%1" != "1"
    echo Not OK
endiff :: done
 
Reference: Rem - Comment - Windows CMD - SS64.com

"In a batch file REM at the start of a line signifies a comment or REMARK, alternatively adding :: at the start of a line has a similar effect."

As TCC.EXE is (almost) 100% CMD.EXE compatible, what works with CMD.EXE usually works with TCC.EXE

Joe
 
Lines beginning with colons are labels -- GOTO and GOSUB targets. A double colon is a fairly useless label, but can be used as a comment.
That's how I always thought of it. So it was a bit of a surprise to see it work at the end of an IFF, ELSE, or ENDIFF line. In my brief testing, it works in those places with or without "&" and REM behaves similarly.
 
Hi Dmitry

I could not find anything about the '::' in the TCC's help…


In my version here (24.00.36) I could find the following line in the Help for REM:

You can also place a comment in a batch file by starting the comment line with two colons [::]. In essence this creates a batch file "label" without a valid label name.


Greetings
 
There are the words 'starting the line' there. The statement does not mean the double colons will work so anywhere in a command line. A command line starting with 'REM ' is ignored as commment, but the 'REM ' after some characters in a line will constitutes a part of a command. The commands
echo the test for rem is OK
echo the test for :: is OK

display all the phrases, not the words before 'rem' or '::'.
 
I've used :: for years instead of REM. Basically, it WOULD create a label named ":". But since there are no "GOTO :" or "GOSUB :" commands it doesn't create a problem.

I never tried it at the end of lines, but I'll definitely start using it--that's one thing I've wanted for a long time but never said anything about it.
 

Similar threads

Back
Top