Re: Learning about dos batch files


[ Follow Ups ] [ Post Followup ] [ The EasyDOS Forum ] [ FAQ ]

Posted by Den on October 07, 2008 at 10:38:39:

In Reply to: Re: Learning about dos batch files posted by 20081007 on October 07, 2008 at 04:10:21:

Great. Thanks.

: : I'm just learning about dos batch files and I'm
: : wondering about the CALL command. If I write a
: : batch file with CALL in it to start another batch
: : file and if the other batch file I'm calling
: : calls another batch file, will it ever come back
: : to the first one? And what if the second (or
: : third) batch file requires user input?

: ##

: Give it a try:

:
: 1) Create the following three BATch files all in the same directory (folder):

: (Copy & paste what's in between the dashed lines into three batch files named 1.bat, 2.bat and 3.bat).

:
: ------------[begin 1.bat]------------

: @echo off
: echo This is 1.bat calling 2.bat
: call 2.bat
: echo This is 1.bat again ... exiting.

: -------------[end 1.bat]-------------


: ------------[begin 2.bat]------------

: @echo off
: echo This is 2.bat calling 3.bat
: call 3.bat
: echo This is 2.bat again ... exiting.

: -------------[end 2.bat]-------------


: ------------[begin 3.bat]------------

: @echo off
: echo This is 3.bat
: echo Press any key to continue ...
: pause>nul
: echo This is 3.bat ... exiting.

: -------------[end 3.bat]-------------


: 2) At the DOS (CMD) prompt, type:

: 1

: and press [Enter].


: 3) You should see:

: This is 1.bat calling 2.bat
: This is 2.bat calling 3.bat
: This is 3.bat
: Press any key to continue ...
: This is 3.bat ... exiting.
: This is 2.bat again ... exiting.
: This is 1.bat again ... exiting.

:
: In other words, it'll work exactly as you expected. 8-)




Follow Ups:



Post a Followup (use TAB key to move between boxes - NOT ENTER or RETURN)

Name:
E-Mail:

Subject:

Type your comments in the box below and SUBMIT:


[ Follow Ups ] [ Post Followup ] [ The EasyDOS Forum ] [ FAQ ]