Reputation: 553
It should be a simple thing, but I'm not getting it
I want to do a call inside a batch file to a label using a variable as a parameter, something like this:
echo off
set TEST=message text
call :MESSAGE %TEST% more text
:MESSAGE
echo %1
what I get is this:
C:\>echo off
message
ECHO is off.
Upvotes: 0
Views: 104
Reputation: 70923
:message
is a label. There is no boundary to avoid the execution to enter the code after it, but this time the code is reached without a parameter to echo and from here the ECHO off
@echo off
set TEST=message text
call :MESSAGE %TEST% more text
goto :eof
:MESSAGE
echo %1
Now the goto :eof
(or exit /b
to leave the batch file or exit
to close the console) avoid the execution to continue into the code after the label
Upvotes: 2