@echo off
set var1=hello
set var2=var1
set var3=var2
echo on
echo 2. %%var3%%
echo.
echo 3. %%%var3%%%
I have echo on
so I can try to make better sense of the batch processing, though it really seems to be limited in parsing info.
When echoing a variable, are the inner/center parts processed first?
I’m trying to understand how multiple percents signs are exactly parsed when surrounding a variable.
I know every other percent symbol cancels out the previous one, but there must be more to it because I can never seem to get the result I think I should.
The logic seems to hold true when I do a simple echo using double percents %%, like so:
echo %%var3%%
Result: %var3%
The outer percent symbol is canceled, and it outputs with single percents: %var3%
So, when I use 3 %%%, I would think it would return %%var3%%
, since ONLY the middle percent of the 3 %%% should be canceled, yet the result is: %var2%
So, obviously I’m not fully understanding how multiple percents surrounding a variable are processed.
When using 2 %%, does the 2nd % cancel the entire process of reading the value from var3
?
Because how else could the result be %var3%
rather than %var2%
?
And b/c the extra % when using 3 %%%, it re-allows the process of reading the value from var3
, which can now extract the value from var3
, which is var2
, and then simply apply the remaining single %s around it to give the final result: %var2%
Am I close or still grasping at straws? Any clarification or suggestions would be appreciated.