(01-29-2024, 11:17 PM)PhilOfPerth Wrote: Noice!Yes, you could easily shell to get drive free space:
Can it also be made to display drive occupancy size?
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