home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Programming Tool Box
/
SIMS_2.iso
/
bp_4_94
/
bonus
/
winer
/
chap11-5.bas
< prev
next >
Wrap
BASIC Source File
|
1992-05-12
|
1KB
|
41 lines
'*********** CHAP11-5.BAS - demonstrates testing for a valid drive
'Copyright (c) 1992 Ethan Winer
DEFINT A-Z
DECLARE SUB ChDrive (Drive$)
'$INCLUDE: 'REGTYPE.BI'
DIM SHARED Registers AS RegType
DEF FnGetDrive%
Registers.AX = &H1900
CALL Interrupt(&H21, Registers, Registers)
FnGetDrive% = (Registers.AX AND &HFF) + 65
END DEF
DEF FnDriveValid% (TestDrive$)
STATIC Current 'local to this function
Current = FnGetDrive% 'save the current drive
FnDriveValid% = 0 'assume not valid
CALL ChDrive(TestDrive$) 'try to set a new drive
IF ASC(UCASE$(TestDrive$)) = FnGetDrive% THEN
FnDriveValid% = -1 'they match so it's valid
END IF
CALL ChDrive(CHR$(Current)) 'either way restore it
END DEF
INPUT "Enter the drive to test for validity: ", Drive$
IF FnDriveValid%(Drive$) THEN
PRINT Drive$; " is a valid drive."
ELSE
PRINT "Sorry, drive "; Drive$; " is not valid."
END IF
SUB ChDrive (Drive$) STATIC
Registers.AX = &HE00
Registers.DX = ASC(UCASE$(Drive$)) - 65
CALL Interrupt(&H21, Registers, Registers)
END SUB