Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @echo off
- ::set default values
- set variable1=hello
- set variable2=world
- set variable3=0
- set version=0.8
- set lastupdated=1/3/2014
- ::If you want to go to help if no arguments are provided, include the following line:
- REM if "%1"=="" GOTO HELP
- if "%1"=="/?" GOTO HELP
- if "%1"=="?" GOTO HELP
- if "%1"=="help" GOTO HELP
- if "%1"=="Help" GOTO HELP
- if "%1"=="HELP" GOTO HELP
- if "%1"=="/h" GOTO HELP
- if "%1"=="--?" GOTO HELP
- if "%1"=="h" GOTO HELP
- if "%1"=="--help" GOTO HELP
- if "%1"=="/help" GOTO HELP
- :Loop
- IF "%1"=="" GOTO Continue
- IF "%1"=="/variable1" set variable1=%2
- IF "%1"=="/variable2" set variable2=%2
- IF "%1"=="/variable3" set variable3=1
- SHIFT
- GOTO Loop
- :Continue
- call:version
- ::--------------------------------------------------------
- ::-- Main program section starts below here
- ::--------------------------------------------------------
- IF %variable3% EQU 0 echo %variable1% %variable2%
- IF %variable3% NEQ 0 echo %variable2% %variable1%
- call:FUNCTION1 "Hello World!"
- GOTO:EOF
- ::--------------------------------------------------------
- ::-- Function section starts below here
- ::--------------------------------------------------------
- :FUNCTION1
- echo The function was called with argument: %~1.
- GOTO:EOF
- :HELP
- call:version
- echo batchtemplate.bat [options]
- echo.
- echo Options:
- echo.
- echo /variable1 [string] The value for variable1 (default is %variable1%)
- echo /variable2 [string] The value for variable2 (default is %variable2%)
- echo /variable3 Echos the values in reverse order (set to non-zero)
- GOTO:EOF
- :version
- echo Version %version% - Last Updated %lastupdated%
- GOTO:EOF
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement