HI GUYS !!! Today were going to learn how to create markers and how to make the user input data .
What are markers ???
They are specified points/line in a commands which have been marked, so that they can be called on later during the execution.
How to make a marker ???
Its simple to create a marker you have to write “:” followed by the marker’s name for eg. “ :marker_name ”
How do we use them ???
We use them with the “ GOTO ” command . The “ GOTO ” command , does exactly what it means !! It goes to the specified point to which it has been referred to (The marker)
[sourcecode]<br />@ECHO OFF<br />: MARK<br />ECHO HELLO WORLD !!!<br />PAUSE<br />GOTO MARK<br />[/sourcecode]
This program is in infinite loop so this will never end .
WARNING !!! : Never use the START command with this type of infinite loops . If you do so you will crash your system.
To create a variable you need to initialize it at the point of creation itself . To create a variable we use the set command. There should be no space in between variable_name and “=” sign. If you are using the variable other than directly to any command you need to enclose them in between”%”. “%variable_name%”
Syntax: set variable_name=2
[sourcecode]<br />@ECHO OFF<br />set x=2<br />echo %x%<br />set y=%x%+2<br />echo %y%<br />set z=y+x //This will give a different value<br />echo %z%<br />[/sourcecode]
INPUT DATA FROM USER
To input data we use the set command .
Syntax: set /p variable_name=
/p is used to pause the execution until the user does an input and presses enter. There should be no space in between variable_name and “=” sign.
[sourcecode]<br />@echo off<br />echo Enter Your name :<br />set /p a=<br />[/sourcecode]
With this we have learnt how to create markers and how to make the user input data and how to create and interact with variables . Next time we will be learning how to create loops.