Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Interesting drive display utility
#6
(01-29-2024, 11:17 PM)PhilOfPerth Wrote: Noice!
Can it also be made to display drive occupancy size?
Yes, you could easily shell to get drive free space:

Code: (Select All)
Rem sample program to get drive space using shell. v1.1a PD 2024.
On Error GoTo Hell
Color 15
Input "Drive letters"; D$
Do
   If InStr(D$, ":") Then D$ = Left$(D$, InStr(D$, ":") - 1) + Mid$(D$, InStr(D$, ":") + 1) Else Exit Do
Loop
Do
   If InStr(D$, "\") Then D$ = Left$(D$, InStr(D$, "\") - 1) + Mid$(D$, InStr(D$, "\") + 1) Else Exit Do
Loop
F = 0
For L = 1 To Len(D$)
   E$ = Mid$(D$, L, 1)
   C# = GetDrive(E$)
   If C# > 0# Then
      Color 14
      Print "Drive "; E$; " bytes free"; C#
      F = F + 1
   End If
   101
Next
Color 15
If F Then Print "Drives found"; F Else Print "No drives found."
End

Hell:
Print "Invalid drive reading "; E$
Resume 101
End

Function GetDrive# (D$)
   D$ = UCase$(D$)
   If D$ >= "A" And D$ <= "Z" Then
      D$ = D$ + ":\"
      ' create default file.
      F$ = D$ + "unknown.ick"
      Open F$ For Output As #1
      Print #1, "testdatafile"
      Close #1
      ' open shell of drive.
      F$ = "DIR " + D$ + "unknown.ick > tempfile.arg"
      Shell _Hide F$
      Open "tempfile.arg" For Input As #1
      Do
         If EOF(1) Then Exit Do
         Line Input #1, X$
         X$ = LCase$(X$)
         If X$ = "invalid drive specification" Then Exit Do
         If InStr(X$, "bytes free") Then
            X$ = Left$(X$, InStr(X$, "bytes free") - 1)
            Z = InStr(X$, "dir(s)")
            If Z Then X$ = Mid$(X$, InStr(X$, "dir(s)") + 7)
            X$ = LTrim$(RTrim$(X$))
            If Len(X$) Then
               Do
                  Z = InStr(X$, ",")
                  If Z Then
                     X$ = Left$(X$, Z - 1) + Mid$(X$, Z + 1)
                  Else
                     Exit Do
                  End If
               Loop
               C# = Int(Val(X$))
               GetDrive = C#
               Exit Do
            End If
         End If
      Loop
      Close
      Kill D$ + "unknown.ick"
      Kill "tempfile.arg"
   End If
End Function


Attached Files
.bas   bytefree.bas (Size: 1.95 KB / Downloads: 15)
Reply


Messages In This Thread
Interesting drive display utility - by eoredson - 12-09-2023, 06:31 AM
RE: Interesting drive display utility - by a740g - 01-29-2024, 09:50 PM
RE: Interesting drive display utility - by eoredson - 01-30-2024, 03:54 AM



Users browsing this thread: 2 Guest(s)