What is batch language?
Batch is a programming language. It is used to create script files executable on Windows operating system. Normally, normally these files have an extension of .bat or *.cmd. When being executed, they open a "Command Prompt" window, which normally has a typical black background, white text.
The batch files (*.bat, *.cmd) are called script files which can contain commands interfering operating system.
Batch uses @rem to start a Comment line, which is used to annotate the purpose of command lines in the program and they are ignored when the program excutes.
To start Batch language, we create a file with the hello.bat name, and write statements showing on the screen the line of "Three", "Two", "One", "Hello World!".
You can also execute Batch file from CMD. Open the CMD and CD programs to go to the folder containing the file to be executed.
The @echo off command is used to stop the command prompt display mode. This mode is on by default. Let's see the difference between @echo off and @echo on by the following illustration:
What is a variable?
Variable is a basic concept in computer science. It is a value that can change. Like other languages, Batch also has the concept of variable.
Basically, Batch has 2 kinds of variables:
Variables are declared in a file through the set command.
Argument variables are passed from outside when the file is called for execution.
Batch language does not have a clear concept of data type. Normally, a variable has the value that is a string, including characters after the = sign to the end of the line. (Including whilte spaces if applicable).
In case you want to declare a variable which is a number, you need to use the set /A statement
To access value of a variable, you must enclose it in % signs