The creator of QB64, Rob, wasn't very enthusiastic about implementing the FILES statement into QB64. He did so for compatibility sake only. FILES is probably one of the least reliable QBasic statements ever made. Now you mentioned you shouldn't see anything printed to the screen, because you didn't use a print statement, but the thing is FILES prints to the screen all by itself! The few times I messed with it, I made a hidden screen to hide the output, and then used the screen command to read the hidden output and place it in string variable. That would work, without intrusion to your working screen, oh, provided the output will fit on the hidden screen without scrolling it! If you have too much output, the screen scrolls, and then reading that screen becomes virtually impossible. Long story short, use something better than FILES.
Substitute routines include error trapping to see if a drive exists (old school for QBasic). Some old school PEEK/POKE routines which I no longer have as I believe they may no longer be supported, not sure, and the _DRIVEEXISTS QB64 command.
Here is a demo with the two examples I mentioned above.
Note that _DIREXISTS only finds the active drives, while the trap method also finds inactive ones, like an optical drive without media present.
If you would like any explanation of how either or both work, let me know. Also, all of us here love the past, so please, please, please never hesitate to post things from the QJurassic Period. A lot of us old dinosaurs here will be happy to help! Come to think of it we only had one Dumbassosaurus in the herd, but he's been extinct for a long time! I guess you could say he went from crude to crude. Oh well.
Pete
Substitute routines include error trapping to see if a drive exists (old school for QBasic). Some old school PEEK/POKE routines which I no longer have as I believe they may no longer be supported, not sure, and the _DRIVEEXISTS QB64 command.
Here is a demo with the two examples I mentioned above.
Code: (Select All)
WIDTH 80, 41
FOR i = 1 TO 26
drive$ = CHR$(i + 64) + ":\"
PRINT drive$,
IF _DIREXISTS(drive$) THEN PRINT "Drive exists: " + drive$ ELSE PRINT
NEXT
PRINT: PRINT "Press a key to run the error trap method."
SLEEP
CLS
ON ERROR GOTO trap
FOR i = 1 TO 26
drive$ = CHR$(i + 64) + ":\"
OPEN drive$ + "null" FOR INPUT AS #1
NEXT
trap:
IF ERR = 53 THEN PRINT "Drive " + drive$ + " exists and is active."
IF ERR = 68 THEN PRINT "Drive " + drive$ + " exists and is inactive."
RESUME NEXT
Note that _DIREXISTS only finds the active drives, while the trap method also finds inactive ones, like an optical drive without media present.
If you would like any explanation of how either or both work, let me know. Also, all of us here love the past, so please, please, please never hesitate to post things from the QJurassic Period. A lot of us old dinosaurs here will be happy to help! Come to think of it we only had one Dumbassosaurus in the herd, but he's been extinct for a long time! I guess you could say he went from crude to crude. Oh well.
Pete
If eggs are brain food, Biden takes his scrambled.