Search found 16 matches
- 02 Aug 2020 15:26
- Forum: DOS Batch Forum
- Topic: FOR variable %%A in macro definition gets overridden when script is called by other script within FOR loop
- Replies: 15
- Views: 2640
Re: FOR variable %%A in macro definition gets overridden when script is called by other script within FOR loop
Success! Thanks to Jeb for the clear explanation and solution provided :D I adjusted the code in the examples and got results as expected in all situations. callee.cmd: @echo off set "$PERCENT=%%%%~$=_p1_FOR-variable_DOLLAR_is_required_while_MACRO_DEFINITION_=:$" FOR %%$ in (DOLLAR) DO ( set "__macr...
- 02 Aug 2020 14:59
- Forum: DOS Batch Forum
- Topic: FOR variable %%A in macro definition gets overridden when script is called by other script within FOR loop
- Replies: 15
- Views: 2640
Re: FOR variable %%A in macro definition gets overridden when script is called by other script within FOR loop
@All, many thanks for responding and giving a lot of information and explanation! @T3RRY, your hints and Jeb's explanation make me wondering, i am going to experiment with the suggestions posted here. @Jeb ahh i see, thanks for the clear explanation. I will try to implement the suggestions and let y...
- 02 Aug 2020 10:33
- Forum: DOS Batch Forum
- Topic: FOR variable %%A in macro definition gets overridden when script is called by other script within FOR loop
- Replies: 15
- Views: 2640
Re: FOR variable %%A in macro definition gets overridden when script is called by other script within FOR loop
Interesting thing i remembered: FOR command also and even accepts unicode characters as variables.
This works.
(using È character with Alt+0456 on numeric keypad)
However, it does not solve the situation.
Code: Select all
for %%È in (test) do echo(%%È
(using È character with Alt+0456 on numeric keypad)
However, it does not solve the situation.
- 02 Aug 2020 09:36
- Forum: DOS Batch Forum
- Topic: FOR variable %%A in macro definition gets overridden when script is called by other script within FOR loop
- Replies: 15
- Views: 2640
Re: FOR variable %%A in macro definition gets overridden when script is called by other script within FOR loop
I don't want to pass the value of a for variable to another script or subroutine, far from that. I want the FOR variable to be left alone when defining the macro. To resummarize, i have accomplished: set __call=for %%A in set "__macro= do (if /i "%%~A" equ "_some value" (echo("some value" detected) ...
- 02 Aug 2020 06:56
- Forum: DOS Batch Forum
- Topic: FOR variable %%A in macro definition gets overridden when script is called by other script within FOR loop
- Replies: 15
- Views: 2640
Re: FOR variable %%A in macro definition gets overridden when script is called by other script within FOR loop
Thus far, the work-around is:
Either i don't define macros within FOR loops, or have such scripts called per line instead of within FOR loops.
Thanks for thinking with me by the way, appreciated!
Either i don't define macros within FOR loops, or have such scripts called per line instead of within FOR loops.
Thanks for thinking with me by the way, appreciated!

- 02 Aug 2020 06:53
- Forum: DOS Batch Forum
- Topic: FOR variable %%A in macro definition gets overridden when script is called by other script within FOR loop
- Replies: 15
- Views: 2640
Re: FOR variable %%A in macro definition gets overridden when script is called by other script within FOR loop
Ah yea :) thought about that too. But chicken-egg problem: Macros are called with a caller macro which uses %%A. Macro definitions use %%A as argument input. The library scripts are called using a macro which uses %%A. Some library scripts define macros wihtin a FOR loop (with whatever %%*, that doe...
- 02 Aug 2020 06:46
- Forum: DOS Batch Forum
- Topic: FOR variable %%A in macro definition gets overridden when script is called by other script within FOR loop
- Replies: 15
- Views: 2640
Re: FOR variable %%A in macro definition gets overridden when script is called by other script within FOR loop
By the way, about: Remember, FOR variables are single-letter, case sensitive, global, and you can't have more than 52 total active at any one time. The documentation is actually incorrect about itself. The 52 characters limitation ought to be based on a-z A-Z. However, 0-9 and other characters like ...
- 02 Aug 2020 06:38
- Forum: DOS Batch Forum
- Topic: FOR variable %%A in macro definition gets overridden when script is called by other script within FOR loop
- Replies: 15
- Views: 2640
Re: FOR variable %%A in macro definition gets overridden when script is called by other script within FOR loop
I see. I know that they are global. The external scripts are, what i call, libraries with macro definitions. That's the reason why they are called externally, to load the macro definitions. These libraries are only called once, to load their macro definitions. And delayed expansion is not acceptable...
- 01 Aug 2020 17:40
- Forum: DOS Batch Forum
- Topic: FOR variable %%A in macro definition gets overridden when script is called by other script within FOR loop
- Replies: 15
- Views: 2640
FOR variable %%A in macro definition gets overridden when script is called by other script within FOR loop
Situation description: I have some scripts which define macros within FOR loops and these macros are called using FOR loops. I have some other scripts which call these scripts within FOR loops. When doing so, i noticed that FOR variables within macro definitions are overridden. I have a work-around,...
- 20 Oct 2019 07:10
- Forum: DOS Batch Forum
- Topic: I need an example
- Replies: 2
- Views: 7058
Re: I need an example
Not sure what you want or how you want it exactly. More specifications of your goal might help. What do you mean with 'the guy'? Is this a set of characters which together look like a guy, like in ASCII art? How do you see 'control'? As in 'move' the set of characters? There are many ways to achieve...
- 09 Oct 2019 22:15
- Forum: DOS Batch Forum
- Topic: Remove Microsoft header from cmd, for example when executing code from alternate data stream
- Replies: 10
- Views: 13588
Re: Remove Microsoft header from cmd, for example when executing code from alternate data stream
I have read about the limitations of alternate data streams, such as NTFS required, not transportable (upload/download/email) and such. Fortunately this is not a problem for the project. NTFS is a requirement of the project because other features of NTFS are also used (file compression/encryption). ...
- 09 Oct 2019 16:29
- Forum: DOS Batch Forum
- Topic: Remove Microsoft header from cmd, for example when executing code from alternate data stream
- Replies: 10
- Views: 13588
Re: Remove Microsoft header from cmd, for example when executing code from alternate data stream
I see, sounds very interesting. Going to experiment with that as well! 

- 09 Oct 2019 15:19
- Forum: DOS Batch Forum
- Topic: Remove Microsoft header from cmd, for example when executing code from alternate data stream
- Replies: 10
- Views: 13588
Re: Remove Microsoft header from cmd when executing code from alternate data stream
I have tried that already like the cmd /C option, that doesn't work as expected.
The solution is to redirect the < cmd option to >nul and to redirect output from inside the stream to >con.
Maar dank je!
The solution is to redirect the < cmd option to >nul and to redirect output from inside the stream to >con.
Maar dank je!

- 09 Oct 2019 14:07
- Forum: DOS Batch Forum
- Topic: Remove Microsoft header from cmd, for example when executing code from alternate data stream
- Replies: 10
- Views: 13588
Re: Remove Microsoft header from cmd when executing code from alternate data stream
Manu thanks for all the great tips! :D Yes I've experienced the funny thing with CLS :P That's a nice idea about redirecting to stderr instead of CON, will do some tests with it. Absolutely right about the cmd /q and prompt no longer necessary, the example was a little piece i wrote quickly. I alrea...
- 09 Oct 2019 11:45
- Forum: DOS Batch Forum
- Topic: Remove Microsoft header from cmd, for example when executing code from alternate data stream
- Replies: 10
- Views: 13588
Re: Remove Microsoft header from cmd, for example when executing code from alternate data stream
Thanks for that quick of response! Sorry, I wasn't implying it was only related to alternate data streams, you are right that the title might suggest it. I changed the title of this topic a bit. Your suggestions fixed the problem! Many thanks! :) I thought I had tested that, but it turns out I forgo...