From Liberty BASIC Family
Jump to navigation Jump to search
Supported in Just BASIC Supported in Liberty BASIC Not supported in Liberty BASIC 5 Not supported in Run BASIC


Contains the letters of all the drives on the computer in use. Drives$ is a special system variable. Use Drives$ anywhere in a program as you would any other variable.


  1. print Drives$


Drives$ is a reserved word and cannot be used as a user-defined variable in a program.
The contents of the variable are not updated, if a removable drive, USB stick and similar, is added or removed!
(changes in available drives will show only after restarting the program)


' A simple example to check if user's computer has an "a:" drive.
if instr(LOWER$(Drives$), "a:") then
    print "There's an a: drive."
    print "No a: drive available."
end if

Useful Procedures

Here is an example from the JB Help file. It searches the user's computer for a list of drive letters and displays the list in a listbox. The user can select a drive letter, possibly to save the current file.

    'a simple example illustrating the use of the Drives$ variable

    dim letters$(25)
    index = 0
    while word$(Drives$, index + 1) <> ""
        letters$(index) = word$(Drives$, index + 1)
        index = index + 1

    statictext #win, "Double-click to pick a drive:", 10, 10, 200, 20
    listbox #win.list, letters$(, [selectionMade], 10, 35, 100, 150
    open "Scan drive" for dialog as #win

    input r$


    close #win