Would you wonderful folks validate this answer to the question? Obviously I'm very new, but I need to solve this problem too:
@echo off
REM define and print debug output for a variable
set a_variable_populated_by_a_function=not useful
@echo on
echo %a_variable_populated_by_a_function% is not useful :(
@echo off
REM call the function, pass in our variable
call :a_function a_variable_populated_by_a_function
REM pointer to where function is complete
:a_function_complete
goto :resume_code
REM function definition
SetLocal
:a_function
set %1=so very useful!
goto :a_function_complete
EndLocal
REM pointer to resume life after function stuff
:resume_code
REM print debug output for variable altered by function
@echo on
echo %a_variable_populated_by_a_function% is so useful :O
@echo off
my output is
not useful is not useful :(
so very useful! is so useful :O
Would the best solution to the question "How do I return a value from a function in a batch file?" require three separate labels / pointers?
:a_function
:a_function_complete
:resume_code
Or maybe these scripts are so messy that "whatever works, works."