Batch scripts are a rudimentary form of scripting language which runs on windows shell. It's usually written in notepad and need be saved with a .bat extension. it's mostly used for handling windows functions and making windows tasks automatic so you don't need to do them manually. It's a procedural language which relies heavily on goto and marks :
The most basic of batch script can be:
@echo off
title grotesquely simple batch script
echo this is a sample batch file
pause
::use @echo off to signal that you don't want the code to show in the actual compiled programme
:: title- the title displayed at the title bar
:: echo . grapahical representation of text
::pause allows stills the screen. without it the programme would run in a blink without enough time to read it
Even though it's mostly used for windows-based chores, it supports code for applications common in mainstream programming languages, like simple calculations:
@echo off
title addition
echo input a number
set /p x=
echo input another number
set /p y=
set /a result=x+y
echo their sum is %result%
pause
::set /p = prompts user's input. set /p x= means that the user's input will be stored on the x variable
::set /a result=x+y means that we are defining a variable named result that is going the the result ensuing from ::the sum of x plus y. Note that we use set when defining variables. and /a tells the compiler that we are ::handling numbers rather than strings
Even though batch scripting doesn't support power functions, it's entirely possible to write code to perform exponential maths
@echo off
title power fubction
:start
cls
echo input power base
set /p x=
echo input power exponent
set /p n=
set result=1
for /L %%i IN (1,1,%n%) do SET /a result*=x
echo result is %result%
pause
goto start