batch-file Functions Function With Parameters


Example

call :tohex 14 result
rem More code...

:tohex <innum> <outvar>
set dec=%1
set outvar=%~2
rem %n and %~n are functionally identical, but %~n is slightly safer.
goto :eof

This takes the additional parameters from the call as if the function was a separate Batch file.
Note: the <parameter> isn't necessary, but it helps with readability.