batch-file Functions Combining them all


Example

set importantvar=importantstuff
call :stuff 123 var1
rem More code...

:stuff <arg1> <arg2>
setlocal
set importantvar=%~1
echo Writing some stuff into %~2!
endlocal
set %~2=some stuff
setlocal
set importantvar=junk
endlocal
goto :eof

This utilizes the basic function, setlocal and endlocal and arguments to create an odd little function.