This filter can be used to redirect any output to a file.Ĭontent writing to files is also done with the help of the double redirection filter >. This filter can be used to redirect any output to a file.Ĭontent writing to files is also done with the help of the redirection filter >. The creation of a new file is done with the help of the redirection filter >. In Batch Script, it is possible to perform the normal file I/O operations that would be expected in any programming language. The ability to completely encapsulate the body of a function by keeping variable changes local to the function and invisible to the caller. Local variables in functions can be used to avoid name conflicts and keep variable changes local to the function. ExampleĪ function is called in Batch Script by using the call command.įunctions can work with parameters by simply passing them when a call is made to the function.įunctions can work with return values by simply passing variables names The EXIT statement is used to ensure that the function exits properly.įollowing is an example of a simple function.
The function_name is the name given to the function which should have some meaning to match what the function actually does. To use a function, you "call" that function with its name and pass its input values (known as arguments) that matches the types of the function's parameters.įollowing is the syntax of a simple function. When a function is newly defined, it may take one or several values as input 'parameters' to the function, process the functions in the main body, and pass back the values to the functions as output 'return types'.Įvery function has a function name, which describes the task that the function performs.
In Batch Script, a function is defined by using the label statement. In batch scripts, a similar approach is adopted to group logical statements together to form a function.Īs like any other languages, functions in Batch Script follows the same procedure −įunction Declaration − It tells the compiler about a function's name, return type, and parameters.įunction Definition − It provides the actual body of the function. A function is a set of statements organized together to perform a specific task.