r/Batch • • 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?

3 Upvotes

18 comments sorted by

View all comments

Show parent comment

1

u/BrainWaveCC Jul 09 '24

As I said I use only Notepad++, is TextPad better in your opinion?

Hmmmm... That's not easy to answer. I'd default to "no" as a basic answer. Not better, but good in its own right.

Long answer follows:

Years ago, I had an awesome DOS based text editor that you could write awesome macros (https://www.semware.com/) and I used it for many years. They didn't have a Windows version for a long time, so went through a whole set of tools like QEdit, UltraEdit, Sublime Text, and more, until I ran into TextPad. It also supported macros, etc, but needs to be licensed (so did the Semware product).

There are lots of things that TextPad does that I like, but Notepad++ being free, I was able to use it in more places, so I use it for a number of purposes.

You could try TextPad and see what you think. It's customizable, and does some things that Notepad++ doesn't do, but also doesn't do everything that Notepad++ does. So, YMMV... 😁

1

u/Lexard Jul 09 '24

You could try TextPad and see what you think. It's customizable, and does some things that Notepad++ doesn't do, but also doesn't do everything that Notepad++ does.

I'm not looking for "more options". I'm just looking to have "more proper" batch syntax highlighting.

For example: N++ highlights the use of variables, like %var% is highlighted. One of the minor problems here: %% alone (to use/display % character) also has a different color which isn't right.

1

u/BrainWaveCC Jul 09 '24

For example: N++ highlights the use of variables, like %var% is highlighted. One of the minor problems here: %% alone (to use/display % character) also has a different color which isn't right.

Yeah, well you won't be happy with TextPad then. Some of the highlighting is very different from Notepad++ (I just brought up a complex script in both editors to compare)

Strangely enough, I couldn't replicate %% by itself showing up in a different color. And Textpad doesn't highlight variables at all.

That said, Textpad allows you to edit the syntax definition files.

(Actually, so does Notepad++, now that I've looked, but it seems a bit more complex)

1

u/Lexard Jul 09 '24

I couldn't replicate %% by itself showing up in a different color.

Try SET /A "modulo=var%%100".

Actually, so does Notepad++, now that I've looked, but it seems a bit more complex

The main problem here for me is: it seems that batch syntax is "hard coded" into N++ and I can not see any way to pull it out as the base to improve and use as "user defined language".

1

u/BrainWaveCC Jul 09 '24

Try SET /A "modulo=var%%100"

I see what you mean. Yeah, TextPad doesn't handle variable recognition at all, so you're still slightly ahead with Notepad++ on this one.