Page 1 of 1

GetDrivePart()

Posted: Tue Jan 15, 2008 6:18 am
by PB
Request a command that does 2 things:

(1) Gets the drive part of a file (or path).
(2) Returns null if it's invalid.

So it could replace this:

Code: Select all

Procedure.s GetDrivePart(path$)
  d$=UCase(Left(path$,3)) : d=Asc(d$)
  If Len(d$)<>3 Or d<65 Or d>90 Or Right(d$,2)<>":\"
    d$=""
  EndIf
  ProcedureReturn d$
EndProcedure

Debug GetDrivePart("c:\boot.ini")  ; Returns "C:\"
Debug GetDrivePart("iexplore.exe") ; Returns ""