T3RRY wrote: ↑02 Jul 2020 13:54
Interesting find. Call may also be used to expand the variable:
Mmmm... Two points about your code.
First, in your example the variable names have
NOT a LineFeed in the name:
Code: Select all
@Echo Off & Setlocal EnableDelayedExpansion
Set ^"var1^
=_1^"
Set ^"var2^
=_2^"
Set var
echo %var1%
echo %var2%
Output:
In the output of
Set var command you can see that "var1" and "var2" are followed by an equal sign
in the same line and that such a variables can be accessed in the
%var1% and
%var2% standard way.
To insert a LineFeed
in the variable name an additional empty line must be included:
Code: Select all
@Echo Off & Setlocal EnableDelayedExpansion
Set ^"var1^
=_1^"
Set ^"var2^
=_2^"
Set var
echo %var1%
echo %var2%
Output:
Code: Select all
var1
=_1
var2
=_2
ECHO está desactivado.
ECHO está desactivado.
In second place, the Call method to expand a variable is used in combination with double percent signs;
NOT with Delayed Expansion:
Code: Select all
@Echo Off & Setlocal
Set ^"var1^
=_1^"
Set ^"var2^
^
=_2^"
Set var
Call Echo %%var1^
:_=Var #%%
Call Echo %%var2^
^
:_=Var #%%
Output:
In this last example note that var2 have
two LineFeeds in its name.
Antonio
PS - The %standard% (one percent) expansion method don't work in this case.