Page 1 of 1
detecting drive letter
Posted: Sun Jun 06, 2004 9:35 am
by Guest
if you're running a QB file off a cd, how can you make it so the program can detect the drive letter (so you can copy files without asking what the cd drive letter is)
This should work
Posted: Wed Jun 09, 2004 6:51 pm
by Guest
CONST MyName$ = "z.bas"
ON ERROR GOTO GetMyErr
FOR i = 90 TO 64 STEP -1
Drive$ = CHR$(i)
FullName$ = Drive$ + ":" + MyName$
MyErr = 0: OPEN FullName$ FOR INPUT AS #1: CLOSE
IF MyErr = 0 THEN EXIT FOR
NEXT i
ON ERROR GOTO 0
IF i = 63 THEN
PRINT "Couldn't find this program anywhere: "; MyName$
ELSE
PRINT "The Drive Letter is "; Drive$
END IF
SYSTEM
GetMyErr:
MyErr = ERR
RESUME NEXT