Example - Calling a Function

An Example showing how it works.

Description: The use of batch functions will divide the script into two sections.
  1. The main script: starting at line 1 ending with a GOTO:EOF command that terminates the script.
  2. The function section: filling the second half of the batch file with one or more functions to be callable from the main script.
Script: Download: BatchTutoFunc1.bat  
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
16.
@echo off

echo.going to execute myDosFunc
call:myDosFunc
echo.returned from myDosFunc

echo.&pause&goto:eof

::--------------------------------------------------------
::-- Function section starts below here
::--------------------------------------------------------

:myDosFunc    - here starts my function identified by it`s label
echo.  here the myDosFunc function is executing a group of commands
echo.  it could do a lot of things
goto:eof
Script Output:
 DOS Script Output
going to execute myDosFunc
  here the myDosFunc function is executing a group of commands
  it could do a lot of things
returned from myDosFunc

Press any key to continue . . .