Drives$

We can learn which drives are installed on a computer natively with the Drives$ statement.

Using Drives$


Liberty BASIC has a special variable called Drives$ which contains a string with a list of drives on the computer. This variable is filled when the program starts. It does not change if the user installs or removes drives during the program's execution. With the advent of removable drives like jump drives, removable CD drives, etc. it may be necessary to check for installed drives at different points during the run of a program. If an updated list of drives is critical during a program's run, use the GetLogicalDriveStringsA API function.

Run this single-line program to see which drives are installed. Insert a jump drive, CD, DVD, etc. and run the program again to see how it changes.

print "Drives$ holds this information: ";Drives$

Extracting Information from Drives$

Drives$ returns a single string containing all drive letters, separated by spaces. We can use WORD$() to extract the individual drive letters.

print "Drives$ holds this information: ";Drives$
d$=Drives$
i = 1   'start with first drive in string
while word$(d$,i)<>""
    print word$(d$,i)
    i = i + 1
wend