{***********************************************************************}
{									}
{ __SetDrFil  Set the default disk drive				}
{									}
{ function  __SetDrFil(Drive : char) : word;				}
{									}
{	      Drive	The drive to make the current default disk.	}
{									}
{ Description __SetDrFil sets the current default disk drive to the one }
{	      specified in the parameter Drive.  The number of drives	}
{	      (diskette and fixed disk drives) is returned as the	}
{	      function value.  For version 3.0 and later, DOS reports	}
{	      at least 5 drives (VDISK	is  installed as one of the	}
{	      reported drives) unless the LASTDRIVE command is used in	}
{	      the CONFIG.SYS file.					}
{									}
{	      If the system has only one diskette drive, it is		}
{	      actually counted as two to be consistent with the phil-	}
{	      osophy of the thinking of the system as having logical	}
{	      drives A and B.  For example, for an XT with a single	}
{	      fixed drive and one diskette drive, the value returned is }
{	      three if DOS 2.x is installed.				}
{									}
{	      If the specified drive is not valid, no action is taken.	}
{									}
{ Version     4.00 (C)Copyright Blaise Computing Inc.  1987		}
{_______________________________________________________________________}

function __SetDrFil(Drive : char) : word;

  var
    Reg       : registers;
    ErrorCode : word;
    NewDrive  : char;

  begin  {__SetDrFil}

    { Before attempting to switch drives make sure the drive is ready.	}
    { If it is not, return the current drive, and set the drive to it	}
    { (so really no action is taken), and thus returning the number of	}
    { drives DOS believes are installed.				}

    if (not __IsDrvFil(Drive,ErrorCode)) then
       NewDrive := __RetDrFil
    else
       NewDrive := Drive;

    with Reg do 		       { Call DOS function $0E		}
      begin			       { DX is set to the drive number, }
	AH := $0E;		       { where 0 = A, 1 = B, etc.	}
	DX := word(UpCase(NewDrive)) - word('A');
	Intr(_DOS,Reg);
	__SetDrFil := word(AL)
      end;

  end;	{__SetDrFil}
