Functions in batch files

To simplify the work with batch files you can use some pseudo-functions to not write one code two times. Here is a sample to prove this:


@echo off

rem call function...
call:myDosFunc 2 2
rem call again...
call:myDosFunc 3 4

echo.&pause&goto:eof


:myDosFunc
echo this is param %~1
echo this is param %~2.
goto:eof



When you use this you have to be carefully to not generate spagheti code; this options is also a posibility to get this programming problem.

 

In the end, you can see two links to get more informations about this subject:

http://www.dostips.com/DtTutoFunctions.php#FunctionTutorial.CreatingAFunction

http://www.commandline.co.uk/cmdfuncs/index.html


Posted by: admin
Posted on: 12/4/2009 at 9:08 AM
Tags: , , , , , ,
Categories: Community | Proxy | Windows
Actions: E-mail | Kick it! | DZone it! | del.icio.us
Post Information: Permalink | Comments (0) | Post RSSRSS comment feed