hi. I dont know much from Dos.
please explaine me this. line by line
@echo off
:aa
echo 1 = 1
echo 2 = 2
echo 3 = 3
echo 4 = 4
echo 5 = exit
set /p yy=selection:
if %yy% equ 5 goto :ex
rem null option to exit?
if "%yy%" equ "" goto :ex
set yy=:menu%yy%
call %yy%
rem loop option here, or "goto :ex" for no loop
goto :aa
:menu1
goto :menux
:menu2
goto :menux
:menu3
goto :menux
:menu4
goto :menux
:ex
exit
:menux
please explaine this for me
Moderator: DosItHelp
-
- Posts: 84
- Joined: 08 Sep 2010 10:25
- Location: Iran,Kashan
- Contact:
-
- Expert
- Posts: 442
- Joined: 01 Aug 2010 17:13
- Location: Canadian Pacific
- Contact:
Re: please explaine this for me
Mohammad_Dos wrote:hi. I dont know much from Dos.
please explaine me this. line by line
Okay.
Mohammad_Dos wrote:@echo off
Prevents the commands in your script from being displayed in the Command Prompt window.
Mohammad_Dos wrote::aa
This is a label "aa" in your script which you can begin processing from at any time with "goto aa".
Mohammad_Dos wrote:echo 1 = 1
This displays "1 = 1" in the Command Prompt window.
Mohammad_Dos wrote:echo 2 = 2
Same as above, except "2 = 2".
Mohammad_Dos wrote:echo 3 = 3
Same.
Mohammad_Dos wrote:echo 4 = 4
Same.
Mohammad_Dos wrote:echo 5 = exit
This displays "5 = exit". These are not commands, just text.
Mohammad_Dos wrote:set /p yy=selection:
This displays "selection:" in the Command Prompt window and waits for you to type something and press enter.
Then it sets the variable "yy" to whatever you typed.
Mohammad_Dos wrote:if %yy% equ 5 goto :ex
If the value of the variable "yy" is equal to 5, go to the label "ex".
Mohammad_Dos wrote:rem null option to exit?
"rem" is like "echo", except no text is displayed in the Command Prompt window.
It is used for comments inside the script, or disabling a line of code.
Mohammad_Dos wrote:if "%yy%" equ "" goto :ex
If the value of the variable "yy" with surrounding quotes is equal to "", that is, nothing, go to the label "ex".
Mohammad_Dos wrote:set yy=:menu%yy%
Set the variable "yy" to ":menu" and it's own current value.
In other words, prefix ":menu" onto itself.
Mohammad_Dos wrote:call %yy%
Executes the value of "yy" as a command. Using "call" may be unnecessary here.
Mohammad_Dos wrote:rem loop option here, or "goto :ex" for no loop
Another comment.
Mohammad_Dos wrote:goto :aa
Go to the aforementioned label "aa".
Mohammad_Dos wrote::menu1
This is the label "menu1".
Mohammad_Dos wrote:goto :menux
This goes to the label "menux".
Mohammad_Dos wrote::menu2
This is the label "menu2".
Mohammad_Dos wrote:goto :menux
This goes to the label "menux".
Mohammad_Dos wrote::menu3
Again...
Mohammad_Dos wrote:goto :menux
Again...
Mohammad_Dos wrote::menu4
Again...
Mohammad_Dos wrote:goto :menux
Again...
Mohammad_Dos wrote::ex
This is the label "ex".
Mohammad_Dos wrote:exit
This closes the current Command Prompt session (cmd.exe).
Mohammad_Dos wrote::menux
This is the label "menux".
-
- Posts: 84
- Joined: 08 Sep 2010 10:25
- Location: Iran,Kashan
- Contact:
Re: please explaine this for me
thanks a lot