Monday, 17 November 2014

How to create a Batch Program -2

No comments :

Explanation of First Batch Program


In this tutorial we are going to learn some more interesting and some technical things about Batch programming. In previous tutorial we have already learn that how to create a simple Bach Program, we also learnt that how to execute it and what are the basic things which we have to have in our mind while we are executing any batch (.bat) program.
form the previous example, can you tell me what was the first line of code :). 
@echo off, this was the line what I am expecting from you. 
                                                            Lets explain it 
'echo’ is the command used to print (Display) text on the screen, so whatever that follows the echo
command will be displayed on the output screen. This command is just like the ‘printf',  statement in the C language, or println in java.
Till now every thing was OK, but problem is why we are using off after it or @ before it if it used for printing something and it is noting printing on screen (from very first echo, second Echo was OK) in the output of the program
                              Let me tell me what was the reason behind it.
When you type the echo command alone, then it will tell you whether the ‘echo is ON’ or ‘echo is OFF’.
It’s always recommended to turn the echo off, else it will display the prompts like (C:\>) and so on. In 
order to avoid the prompts being displayed, the echo is turned off by using the command “@echo off” or 
simply by using the “echo off”.
Please have a look on your own code and try to do whatever I have told you in the previous explanation. 

Explanation of last two lines:- 
1.“Echo Hello World” will display the “Hello World” on the output screen, and the 2. pause command is used to wait for the user interaction, whether to proceed further or not. If the pause is not used, then the batch will terminate immediately after displaying the “Hello World”. In this case you may not able to see the output of the above program. 

This is all about your previous program what we done before. In the next tutorial we will going to explore something about type of command, I can understand that you might thing that I am using command word more frequently but what is command, we haven't read anything interesting about it. in the next tutorial we are going to have a very nice drive of commands in Batch programs.

No comments :