Call a label as a variable
Posted: 25 May 2011 13:53
Pretty sure this can't be done using something like...
...but I do not understand how or what is happening here...
...why the above works but if I change it to...
...it does not work, is it because I am redefining label as label again...?
I am confused. It would appear in the second example due to the escape chars, all that is happening is that
it is looking for !LABEL! as the label which exist so it calls it, but then why doesn't !ONE! respond the same way? Further more this test baffles me completely...
...why is label now being declared as goto...
Does it really matter, no probably not, just curiousness.
Code: Select all
set label=LABEL
call :%label%
goto :eof
:%label%
echo.HERE
...but I do not understand how or what is happening here...
Code: Select all
@echo off&&setlocal
setlocal enabledelayedexpansion
set label=^^!LABEL^^!
call :%label%
goto :eof
:!LABEL!
echo.HERE
...why the above works but if I change it to...
Code: Select all
@echo off&&setlocal
setlocal enabledelayedexpansion
set label=^^!ONE^^!
call :%label%
goto :eof
:!ONE!
echo.HERE
...it does not work, is it because I am redefining label as label again...?
I am confused. It would appear in the second example due to the escape chars, all that is happening is that
it is looking for !LABEL! as the label which exist so it calls it, but then why doesn't !ONE! respond the same way? Further more this test baffles me completely...
Code: Select all
@echo off&&setlocal
set label=^^%label^^%
call :%label%
goto :eof
:goto
echo.HERE
...why is label now being declared as goto...
Does it really matter, no probably not, just curiousness.