@aGerman - thank you - your explanation makes perfect sense.
Ed Dyreen wrote:'
aGerman wrote:You should avoid leading numbers in variable names. The reason why is simple:
%2echo_%
Is %2 an argument or is it part of a variable?
Your conclusion is not correct, it doesn't explain, next behavior on XP:
Code: Select all
@echo off
set "2echo_=>&2 <nul set /p ="
%2echo_% Hello
pause
set "2echo=>&2 <nul set /p ="
%2echo% Hello
pause
As you can see it's the combination of both a leading digit and an ending "special" character that is causing it !Code: Select all
echo_ wordt niet herkend als een interne
of externe opdracht, programma of batchbestand.
Druk op een toets om door te gaan. . .
Hello
Druk op een toets om door te gaan. . .
DOS tells me,
it can't decide whether it is part of a variable because of the underscore at the end.Remove the ending underscore, and DOS will accept it as a variable...
Ed - I'm not getting the same results as you.
All macro variants that begin with a number fail for me on
both Vista and XP within a batch, even if there is no underscore on the end. All variants that do not begin with a number succeed. This is the behavior I expect with aGerman's explanation.
If I run the macros from the command line, then all variants work, again backing up aGerman's explanation since the command line does not attempt batch argument expansion.
The failures you are getting only occur in batch, correct
You can run your batch with 2 arguments passed in and you should see the 2nd argument as part of your error message for the %2echo_% case.
The big mystery is why the %2echo% variant works in batch mode for you.

You did test it in batch mode, yes
Have you loaded and/or executed any of your macros prior to testing
I'm thinking of the macros that exhibit the nasty XP FOR /F bug. I know that you are suppressing and/or ignoring the FOR /F error messages. I'm worried that if you run such macros and then run your ECHO macro tests, your machine might be in an unstable state. Try running the ECHO macro test with minimal code in a virgin CMD window.
Dave Benham