BATCH FILES
-----------

	     When a command is given to MSX-DOS and it is not one of
	the  internal commands,  a file of that name is searched for
	with an extension of COM or BAT. If not found in the current
	directory  then  the current search path  is  searched  (see
	HELP PATH).  If a COM file is found,  then it is loaded  and
	executed.  If  a  BAT  file is found,  then  MSX-DOS  starts
	execution of the batch file.

	     A  batch  file is a text file that contains a  list  of
	commands,  and these commands are read from the file a  line
	at  a  time  and executed as though they were typed  at  the
	keyboard.  Several  MSX-DOS  commands are in  fact  provided
	mainly for use in batch files, such as ECHO and PAUSE.

	     As  each  command  is read,  normally  it  is  executed
	immediately.  An environment item ECHO exists, however, that
	can  be  set to ON (with the command SET ECHO ON)  to  cause
	each  command line to be printed on the screen before it  is
	executed  (HELP  ENV  on  Environment  Items).  The  command
	line  is  echoed in this way after % parameter  substitution
	(see below) has taken place.  The command SET ECHO OFF  will
	restore the normal state.

	     In  the  command  line  that invoked  the  batch  file,
	parameters  may follow the name of the batch file just  like
	any   other  command  or  transient  program   name.   These
	parameters  may  be accessed anywhere in the batch  file  by
	specifying %0 to %9.  %1 is the first parameter,  %2 is  the
	second  and so on.  %0 is the name of the batch file itself.
	The  %  number  will be replaced by  the  parameter  on  the
	original  command line,  and may appear anywhere on a  batch
	file  command line.  To actually use a % symbol on a command
	line  a  double % must be given ('%%') which  will  then  be
	replaced by a single one.

	     If  the  execution  of any command in a batch  file  is
	terminated  prematurely  for  some  reason  (typically   the
	control-STOP  or  control-C  key  being  pressed)  then  the
	following prompt is issued:

		  Terminate batch file (Y/N)?

	If the response to this is 'Y',  then execution of the whole
	batch file is stopped.  If the response is 'N',  then  batch
	file  execution continues with the next command in the batch
	file.

	     After MSX-DOS has executed a command in batch file,  it
	may  need  to  read the next command in the batch  file  off
	disk.  If the correct disk is not in the drive when it comes
	to  do  this,  then a prompt is  issued.  For  example,  the
	following  prompt  will  be issued if  the  batch  file  was
	originally executed from drive A:

		  Insert disk for batch file in drive A:
		  Press any key to continue...

	When  the correct disk has been inserted and a key  pressed,
	batch file execution will continue normally.

	     Below  is a very simple batch file,  which just  prints
	the first few parameters.

		  ECHO Parameter 0 = %0
		  ECHO Parameter 1 = %1
		  ECHO Parameter 2 = %2
		  ECHO Parameter 3 = %3

	     If  this is called MYBAT.BAT then the command MYBAT a b
	c will output

		  Parameter 0 = MYBAT
		  Parameter 1 = a
		  Parameter 2 = b
		  Parameter 3 = c

	     When  MSX-DOS starts up for the first time,  a  special
	batch   file  called  AUTOEXEC.BAT  is  looked  for  and  is
	executed if found. This may contain any MSX-DOS command, and
	usually contains once-only initialization commands,  such as
	a RAMDISK command to set up a RAM disk.

	     One % parameter is passed to AUTOEXEC.BAT as  %1.  This
	the  drive that MSX-DOS booted from and is in the form of  a
	normal drive letter followed by a colon.

	     Another  special  batch  file is  REBOOT.BAT.  This  is
	executed  when MSX-DOS is re-booted after using  some  other
	application  (such  as  the built-in  MSX  BASIC).  As  with
	AUTOEXEC.BAT  files,  the single %1 parameter passed is  the
	drive from which MSX-DOS was re-booted.

	     Usually  some  commands need to be  performed  whenever
	MSX-DOS  is booted,  whether for the first time or  sometime
	later,  and these are put in the REBOOT batch file. They can
	then  be executed from the AUTOEXEC batch file by ending  it
	with  the command REBOOT %1.  An example of a  command  that
	might be put in the REBOOT batch file is the PATH command to
	set  up the transient command search path.  When setting  up
	the search path using the command,  %1 can be used to set up
	the path on whatever drive was booted from.

	     When  a command in a batch file is the name of  another
	batch  file,  then that second batch file is executed in the
	normal  way.  When  it  ends,  control passes  back  to  the
	interactive command interpreter,  and not to the first batch
	file. Batch file commands thus 'chain' together.

	     If  it  is desired to 'nest' batch files  i.e. to  pass
	control back to the first batch file above, then this can be
	done with the COMMAND2 command (see HELP COMMAND2),  passing
	the  name  of the second batch file as the  parameter.  Then
	when  the  second batch file ends,  the first  one  will  be
	continued with the command after the COMMAND2 command.
	     A typical AUTOEXEC batch file is as follows:

		  ECHO AUTOEXEC executing
		  RAMDISK 100
		  RAMDISK
		  COPY COMMAND2.COM H:\
		  REBOOT %1

	     A typical REBOOT batch file is as follows:

		  ECHO REBOOT executing
		  PATH H:\, %1\UTILS, %1\BATCH
		  SET SHELL=H:\COMMAND2.COM
		  SET TEMP=H:\
		  SET PROMPT ON
		  H:

	     When  the  AUTOEXEC batch file  executes,  the  message
	"AUTOEXEC executing" is printed,  and then a RAM disk is set
	up with a maximum size of 100K.  Another RAMDISK command  is
	then  given which will print out the actual size of RAM disk
	created.  The COPY command then copies COMMAND2.COM onto the
	RAM  disk so that it can load and re-load  quickly.  Finally
	the  REBOOT batch file is executed,  with the  %1  parameter
	(the boot drive) passed to it.

	     The REBOOT batch file prints a message and then sets  a
	PATH. The first item in the path refers to the RAM disk that
	was created by the AUTOEXEC batch file,  and the other items
	refer  to  directories  on the disk from which  MSX-DOS  was
	booted  (i.e. %1).  The SHELL environment item is set up  so
	that COMMAND2.COM can re-load quickly off the RAM disk,  and
	the TEMP environment item is set up so that temporary piping
	files are created on the RAM disk.  The prompt is set ON  so
	that  the  current directory is printed as the  prompt  and,
	finally, the RAM disk is made the default drive.
