In general, Function is a block of code which can be called multiple times from any point in program. Function may receive input and it may return output after processing.
- Function with No input and no output returned
::To demonstrate the functions @echo off ::call to function call :helloworld ::return after function call exit /B %ERRORLEVEL% ::function definition starts :helloworld echo Hello World pause exit /B 0 ::function definition ends
Output

2. Function that receives input but returns no output
::To demonstrate the functions @echo off ::call to function with 2 parameters call :WishMessage Peter Indiana exit /B %ERRORLEVEL% ::Function definition starts :WishMessage ::%~n is used to refer input parameters echo Hello Good Morning %~1 %~2 pause exit /B 0 ::Function definition ends
output

3. Function that receives input and returns some output
::To demonstrate the functions @echo off call :WishMessage Peter Indiana value1 echo today is %value1% exit /B %ERRORLEVEL% :WishMessage echo Hello Good Morning %~1 %~2 set value1=Monday pause exit /B 0
Output








