Batch Programming

 Batch Programming


  • Batch file programming is a way of making a computer do things simply by creating a batch file.

  • Batch programming is a programming paradigm that can execute certain commands automatically at the level of an operating system such as DOS or Windows 7 / XP. 

  • A batch file is a stack of such commands. If it is retrieved with the command line, the system will execute each task listed in succession. 

  • Batch files are often used to control and configure operating systems, but can also be used for other operations such as server installations. 

  • A batch file is a collection of instructions that are used to run multiple commands at a time. It is a bundle of packages that are written In a sequence so that the user does not have to put commands and instructions again and again. These files contain .bat extension. This means that you have to save the batch files by using the .bat extension at the end of the file name. These are DOS commands and also can run on command prompt.


Batch file function example: Program demonstrating function with return values

@echo OFF

CALL :retun_value_function ret_val1,ret_val2

ECHO The square root of %ret_val1% is %ret_val2%

PAUSE

EXIT /B %ERRORLEVEL% 

:return_value_function

SET %~1=100

SET %~2=10

EXIT /B 0

@echo off

SETLOCAL

CALL :SetValue value1,value2

echo %value1%

echo %value2%

EXIT /B %ERRORLEVEL%

:SetValue

set "%~1 = 5"

set "%~2 = 10"

EXIT /B 0



Batch file function example: Program demonstrating function with parameters

@echo OFF

CALL :param_function 20, 400

EXIT /B %ERRORLEVEL% 

:param_function

ECHO The square of %~1 is %~2

PAUSE

EXIT /B 0



http://www.trytoprogram.com/batch-file-for-loop/ 


No comments:

Post a Comment

Monk and Inversions

using System; public class Solution { public static void Main () { int T = Convert . ToInt32 ( Console . ReadLine...