Change Drive Source for QB45 
Author Message
 Change Drive Source for QB45

Yes, some QuickBasic code for a change. ;-)

Unlike powerbasic, PDS, etc. QuickBasic 4.5 does not have a CHDRIVE
command. You can use CHDIR to change directories, but there is no build-in
command to change to a different drive. The snippet below will take care of
that...

(N.B. -- it uses interrupts, so you'll have to load QB with the /L option!)

'-------------------------------------------------------------------------
' ChangeDrive for QuickBasic 4.5
' Public Domain, June 1998
' Created by Marc van den Dikkenberg
'
' The PowerBasic Archives -- http://www.*-*-*.com/ ~excel/pb.html
' All Basic Code Archives -- http://www.*-*-*.com/ ~excel/pbabc.html
'
'-------------------------------------------------------------------------

'$INCLUDE: 'qb.bi'

DIM SHARED InReg AS RegType
DIM SHARED OutReg AS RegType
DECLARE SUB CHDRV (drive AS STRING)

CLS

CHDRV "C"
CHDIR "\":  ' Change back to root, instead of current directory
FILES

SUB CHDRV (drive AS STRING)
   ' First check if the drive you want to access exists...
   '
   DIM drivename AS STRING * 4
   DIM buff AS STRING * 128
   drivename = UCASE$(LEFT$(drive, 1)) + ":\" + CHR$(0)
   InReg.AX = &H6000
   'InReg.DS = VARSEG(DriveName)
   InReg.SI = VARPTR(drivename)
   'InReg.ES = VARSEG(Buff)
   InReg.DI = VARPTR(buff)
   Interrupt &H21, InReg, OutReg
   '
   IF LEFT$(buff, 1) <> CHR$(0) THEN
      ' If the drive exists, change it to be the default drive.
      '
      DriveNumber% = ASC(UCASE$(LEFT$(drive$, 1))) - 65
      InReg.AX = &HE00
      InReg.DX = DriveNumber%
      Interrupt &H21, InReg, OutReg
'     PRINT OutReg.AX MOD 256: ' <-- returns the LASTDRIVE=.. Value
   ELSE
      ' If the drive does NOT exist, generate a "Path Not Found" error.
      ' Of course you can remove this error statement, and replace it
      ' with something of your own to tell the main program that the
      ' operation has failed.
      ERROR 76
   END IF
END SUB

--
Marc van den Dikkenberg
-----------------------
The PowerBasic Archives
http://www.*-*-*.com/ ~excel/pb.html



Thu, 23 Nov 2000 03:00:00 GMT  
 Change Drive Source for QB45



Quote:
>Yes, some QuickBasic code for a change. ;-)

>Unlike PowerBasic, PDS, etc. QuickBasic 4.5 does not have a CHDRIVE
>command. You can use CHDIR to change directories, but there is no build-in
>command to change to a different drive. The snippet below will take care of
>that...

[snip...snip]

Wouldn't a simple SHELL command be a lot easier?  If necessary,
redirect output to catch errors.
--
Reply Addr:-->WDavid dot Simon at ATL dot frb dot org<--



Fri, 08 Dec 2000 03:00:00 GMT  
 Change Drive Source for QB45

Quote:



> >Yes, some QuickBasic code for a change. ;-)

> >Unlike PowerBasic, PDS, etc. QuickBasic 4.5 does not have a CHDRIVE
> >command. You can use CHDIR to change directories, but there is no build-in
> >command to change to a different drive. The snippet below will take care of
> >that...
> [snip...snip]

> Wouldn't a simple SHELL command be a lot easier?  If necessary,
> redirect output to catch errors.

I do not not believe this would work. If it did, it would have been
done a long time ago. Shell command should only switch drives for the
duration of the 2nd
command interpreter duration. It would be useless for a permanent
drive change.

Quote:
> --
> Reply Addr:-->WDavid dot Simon at ATL dot frb dot org<--


--
I have had my Switchblade Symphony Fix for Spring 1998.
[05-18-1998 2310 hours to 2340 hours  Live Contact: 0010 - 0028 :> ]
Have you had your SS fix yet?
Have a Nice Evening Nighttime.


Sat, 16 Dec 2000 03:00:00 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. QB45 - Safe with data compressed drives?

2. QB45 Huffman Source

3. Mazer game. (1/1) QB45 source included

4. VB 3.0 EXEs change without changing the sources

5. Drive Ready source for Po

6. VB4 help: Can't save source to network drive

7. VB4 help: Can't save source to network drive

8. Change to a Mapped network drive

9. Linked table manager to be changed from (X:\) a server drive to (C:\) a local machine

10. Macro to change to network drive and specific directory

11. Change of network drive for reports

12. Changing a Drive

 

 
Powered by phpBB® Forum Software