detecting drive letter

Please use this Board for QBasic related requests ( file research, programming, etc.)

Moderators:Administrator, Global Moderator

Post Reply
Guest
detecting drive letter

Post by Guest » Sun Jun 06, 2004 9:35 am

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)

Guest

This should work

Post by Guest » Wed Jun 09, 2004 6:51 pm

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

Post Reply