🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: alt.msdos.programmer
Article #664

How DOS executes batch files [was: Another MsDos batch programming chal

#664
From: ccdps
Date: Mon, 28 Sep 1992 22:41
59 lines
3225 bytes
In article <1992Sep7.211129.702@csc.canterbury.ac.nz>, cctr132@csc.canterbury.ac.nz (Nick FitzGerald, CSC, Uni. of Canterbury, NZ) writes:
> In article <1992Sep4.213842.14734@mits.mdata.fi>, kennu@mits.mdata.fi
> (Kenneth Falck) writes:
>> In article <1992Sep4.032836.7299@cs.ubc.ca> yogi@cs.ubc.ca (Yossi Gil)
> writes:
  [deleted]
> The actual DOS batch processor is a tad more involved than Yossi's
> outline suggests.  Whilst the following may not seem much different from
> what Yossi suggests, some subtle implications of batch processor
> operations are more clearly apparent from it.  To the best of my ability
> to tell, the following is a more accurate outline:
>
>  1.  Open file
>  2.  Read first line
>  3.  Note number of -chars- read thus far
>  4.  Parse line (for redirection, etc)
>  5.  Close file
>  6.  Execute command
>  7.  Open file
>  8.  Read to number of chars recorded in 4.
>  9.  Read to next EOL or EOF
> 10.  If command is null and EOF goto 12.
> 11.  Loop to 3.
> 12.  Close file
>
 [STUFF deleted]

I have done some quick checks with a crude interrupt tracer to
determine what happens with REMs and labels. I have the following
modifications:

  1.  Open file
  2.  Read line
  3.  Note number of -chars- read thus far
  4.  Parse line (for redirection, etc)
  5.  If line is a label, note position and do step 2
  6.  If line is a forward GOTO, keep reading until label found, then do step 2
  7.  If line is a backward GOTO...? (I haven't tested this yet)
  8.  Close file
  9.  Execute command
 10.  Open file
 11.  Read to number of chars recorded in 3  [I think Nick meant 3 here, not 4]
 12.  Read to next EOL or EOF
 13.  If command is null and EOF goto 15.
 14.  Loop to 3.
 15.  Close file

This confirms what simple ECHO ON observation says: REMs get executed and labels
don't. At UniSA we have for years been skipping rather long documentation
sections in our LAN batch files with a GOTO, because the batch processor
*doesn't* close and open the file to read every line regardless. This also
supports the very old trick of using ": " to begin a comment rather than
a REM. The space after the ":" ensures that there are no confusions between
real label names and comments.

--
 Dan Shearer                        email: Dan.Shearer@UniSA.edu.au
 Computer Centre                    Phone: +61 8 302 3479
 University of South Australia      Fax  : +61 8 302 3385
Technical Details
Message-ID: <18821.2ac97d45@levels.unisa.edu.au>
Path: arc1-ca.pugleaf.net!sparky!uunet!zaphod.mps.ohio-state.edu!wupost!spool.mu.edu!umn.edu!msus1.msus.edu!levels!ccdps
References: <israel.715477510@unixg.ubc.ca> <1992Sep3.214401.5000@uwasa.fi> <1992Sep4.032836.7299@cs.ubc.ca> <1992Sep4.213842.14734@mits.mdata.fi> <1992Sep7.211129.702@csc.canterbury.ac.nz> <18812.2ac80fc0@levels.unisa.edu.au>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!sparky!uunet!zaphod.mps.ohio-state.edu!wupost!spool.mu.edu!umn.edu!msus1.msus.edu!levels!ccdps
Newsgroups: alt.msdos.programmer
Subject: How DOS executes batch files [was: Another MsDos batch programming chal
Message-ID: <18821.2ac97d45@levels.unisa.edu.au>
From: ccdps@levels.unisa.edu.au
Date: 29 Sep 92 08:11:44 +0930
Followup-To: alt.msdos.programmer,comp.os.msdos.programmer
References: <israel.715477510@unixg.ubc.ca> <1992Sep3.214401.5000@uwasa.fi>  
 <1992Sep4.032836.7299@cs.ubc.ca> <1992Sep4.213842.14734@mits.mdata.fi> 
 <1992Sep7.211129.702@csc.canterbury.ac.nz> <18812.2ac80fc0@levels.unisa.edu.au>
Organization: University of South Australia
XPosted: ccdps@levels.unisa.edu.au
XNewsgroups: comp.os.msdos.programmer
Lines: 59