07-29-2022, 03:00 PM
(This post was last modified: 07-29-2022, 04:12 PM by JRace.
Edit Reason: squish platform-specific bug
)
Count the lines in your output display. It looks like FILES is printing something for each drive that you check for.
In your screenshot, "C:\USERS\BOB\QB64\SOURCE\FILE" is the last directory successfully listed.
It looks like the extra text lines are being printed by the FILES statement, with one line printed for each non-existent drive that the program checks for.
I added a line to your program, "Print "{{{ "; Drive$; " }}}", directly above the FILES line. Screenshot of test run:
The PRINT statement tells us which drive is being checked for.
Note how FILES prints the name of the current working directory for each non-existent drive that it is run for.
Instead of FILES, you might try the _DIREXISTS function (https://qb64phoenix.com/qb64wiki/index.php/DIREXISTS), looking for "/" (the root directory) on each drive:
"A:/"
"B:/"
"C:/"
and so on. I'm using the forward slash (instead of the Windows-specific backslash) for multi-OS compatibility.
Here's a quick test, which works on my Win7 machine (although it does not show my DVD drive, E:, since that drive is empty):
In your screenshot, "C:\USERS\BOB\QB64\SOURCE\FILE" is the last directory successfully listed.
It looks like the extra text lines are being printed by the FILES statement, with one line printed for each non-existent drive that the program checks for.
I added a line to your program, "Print "{{{ "; Drive$; " }}}", directly above the FILES line. Screenshot of test run:
The PRINT statement tells us which drive is being checked for.
Note how FILES prints the name of the current working directory for each non-existent drive that it is run for.
Instead of FILES, you might try the _DIREXISTS function (https://qb64phoenix.com/qb64wiki/index.php/DIREXISTS), looking for "/" (the root directory) on each drive:
"A:/"
"B:/"
"C:/"
and so on. I'm using the forward slash (instead of the Windows-specific backslash) for multi-OS compatibility.
Here's a quick test, which works on my Win7 machine (although it does not show my DVD drive, E:, since that drive is empty):
Code: (Select All)
DefInt A-Z
found$ = ""
For test = Asc("A") To Asc("Z")
lookfor$ = Chr$(test) + ":/"
If _DirExists(lookfor$) Then found$ = found$ + Chr$(test)
Next
Print found$