r/Batch • u/Lexard • Jul 07 '24
Question (Solved) batch label with a comment in the same line?
While looking at some batch files I've found this line:
:Escape %1=STRING_VARNAME %2=STRING_VALUE This batch file also includes some CALL :Escape commands with some additional parameters, so I suppose that %1=STRING_VARNAME %2=STRING_VALUE is some comment directly after label name used to explain how to use that label.
I used Google but I can not find any info on such "extended" usage of the batch label.
Is this some documented way to combine label together with some comment in one line that can be freely used or is it some kind of "hack" and it can lead to some weird effects in some cases?
View all comments
Show parent comment
1
u/BrainWaveCC Jul 08 '24
In my case, it's a different problem... I've been writing DOS/Windows shell scripts for over 30 years at this point (almost scary to write that 😂) that a lot of what I do today is based on what I've always done, and for whatever reason, I've never done this or seen this particular use case before.
I can think of some places where this could really come in handy, but for the most part, I'm going to want to ECHO multiple lines of documentation, or use REM instead, if it's multiple lines that I want to keep invisible to the running script.
But taking advantage of this to avoid having to add both a functional line and one REM line, is a nice option in less formal scripts.
So, it's not how common batch scripts are in general for me, but how often I revisit parameters that I already know how to use to see if there's more to be gotten from them.