@echo off
echo Hello World !
pause
"echo off" is the command which hides the prompt of where the bat files is launched ; e.g (C:/ >),
sure you can turn on the echo off (Prompt display) but it will shows every line of the assembly code (it will work at simple programming level but it definitely won't work at more advance level) and it will be a little bit messy for the user.
The above figure shows what happens when you do not include "@echo off"
I include the more variance of the sample Hello World ! programs.
V1:
@echo off
echo Hello World !
pause
V2:
@ECHO OFF
ECHO Hello World!
PAUSE
If you test the both batch samples, the programs should actually works in Vista as batch programming is case insensitive in nature.
"echo" on other hand is the command which display the result from the batch programs to the output.
You can use the echo to broadcast any messages you like or even display the output after receives input from the user.
If you ever learnt C programming language, it is very similiar to printf command.
You can try to customize the messages into your own style such as below.
@echo off
echo ######################################
echo # Welcome to zeushammer.blogspot.com #
echo ######################################
pause
You can broadcast any kind of messages as long as it is ANSI supported characters.
Now we move on to the last components of batch programmings
The purpose of pause command is to hold all the operations while waiting for users to input to proceed. (P.S: It is not always necessary means to end the programs). It will be marked by : "Press any keys to continue . . . "
If you try to program without using pause , the program will simply end itself and you can't even view the messages broad casted. :(
In the next tutorial part, I will teach you how to customize the batch programs display.
No comments:
Post a Comment