Path: utzoo!utgpu!news-server.csri.toronto.edu!rutgers!ukma!usenet.ins.cwru.edu!agate!violet.berkeley.edu!jkelly From: jkelly@violet.berkeley.edu (John Kelly;;25241;;LN41) Newsgroups: comp.os.msdos.programmer Subject: Re: Batch Files Summary: Line-by-line, yes; return to first batch file, no. Keywords: MS-DOS, batch files Message-ID: <1991Jun19.064921.16122@agate.berkeley.edu> Date: 19 Jun 91 06:49:21 GMT Expires: Thu, 1 Jan 1970 00:00:00 GMT References: <49377@ut-emx.uucp> <91146.162307IO92203@MAINE.MAINE.EDU> Sender: jkelly@violet.berkeley.edu (John Kelly) Distribution: usa Organization: University of California, Berkeley Lines: 39 In article <91146.162307IO92203@MAINE.MAINE.EDU> IO92203@MAINE.MAINE.EDU (Scott Maxell) writes: >A batch file is opened, one line is read from it, then closed, then the line >is executed. If a batch file calls another batch, that line will be read, the >line marker for the first file saved, then the next batch runs. After that >batch file finishes executing, the first is opened again and the next line >is read. What version of MS/PC-DOS are we talking about here? In the versions I know only too well (up to 3.21), this does NOT happen (would that it did!). When a batch file calls another batch file, control transfers to the called file and never returns--unless you make the call using the syntax "command /cSECOND.BAT". This loads another copy of command.com with instructions to execute SECOND.BAT; when that copy of command.com finishes, it exits to the original batch file and goes on. For example, given: FIRST.BAT SECOND.BAT echo This is line 1 of FIRST echo Line 1 of SECOND second echo Line 3 of FIRST you will never see the message "Line 3 of FIRST". You have to rewrite FIRST.BAT: echo This is line 1 of FIRST command /cSECOND echo Line 3 of FIRST Right, I just said it couldn't be done and then told you how to do it. It's late and I should be in bed. Anyway, my point is that you can't do it by just calling the second batch file--you have to jump through a hoop. Remember, MS-DOS was originally designed to run on 64K IBM PC's; it's no wonder we have to twist it up like a pretzel to make it do the things a real operating system does. Scott is right about the line-by-line reading and executing. That's why it's so easy to get the message "Insert disk with batch file and press any key to continue."