Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- Force 4.0 Reference - selectdrive() change the current drive http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
 selectdrive()       Change the current drive
------------------------------------------------------------------------------
 Declaration
   file.hdr

 Syntax
   proc selectdrive extern
   param value uint uDrive

 Arguments
   uDrive is the drive number to select. 0 means drive A:, 1 is
   drive B:, etc..

 Return
   None.

 Description
   The selectdrive() procedure changes the current drive to uDrive.
   selectdrive() only manipulates the current drive, not the current
   directory.

   If the drive requested is invalid, then selectdrive() returns without
   changing the drive. Use the curdrive() function in conjunction with
   selectdrive() to assure the drive requested is valid (see examples).

   If the drive requested is not ready (i. e. there is no disk in the drive)
   then the critical error handler is called by DOS.

 Example
   #define EXAMPLE_FILE
   #include example.hdr

   proc ValidDrives
   param char( 1 ) aDrives[]
   // Fill an array of valid drives
   vardef
      uint nLetter
      uint n
      uint nCurDrive
   enddef
   nCurDrive := curdrive()      // save current drive
   nLetter := 0
   for n := 'A' to 'Z'          // test all drive characters
      selectdrive( nLetter )    // attempt to switch to a drive
      if nLetter == curdrive()  // if successful
         aDrives[ nLetter ] := chr( n ) // store drive letter in array
      else
         aDrives[ nLetter ] := ""       // put an empty string if no drive
      endif
      nLetter++                 // next drive
   next
   selectdrive( nCurDrive )     // restore original drive
   endproc
   
   proc Test_selectdrive
   vardef
      char( 1 ) aDrives[ 26 ]
      uint      n
   enddef
   ValidDrives( aDrives[] )
   ? "Valid drive letters are:"
   for n := 0 to 15
      if .not. isempty( aDrives[ n ] )
         ? aDrives[ n ]
      endif
   next
   endproc

   proc main
   Test_selectdrive()
   endproc

See Also: chdir()

Online resources provided by: http://www.X-Hacker.org --- NG 2 HTML conversion by Dave Pearson