detecting drive letter
Moderators:Administrator, Global Moderator
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
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
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