GetDrivePart()

Got an idea for enhancing PureBasic? New command(s) you'd like to see?
PB
PureBasic Expert
PureBasic Expert
Posts: 7581
Joined: Fri Apr 25, 2003 5:24 pm

GetDrivePart()

Post 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 ""
I compile using 5.31 (x86) on Win 7 Ultimate (64-bit).
"PureBasic won't be object oriented, period" - Fred.