
Which reminds me, didn't I see something recently about internet "name spaces"? Basic IIRC all URL's will eventually start with "<NAMESPACE>:...".
@Fred: Adopt my suggestions and get waaaay ahead of the curve

Code: Select all
Procedure.s URLHostPart(u.s)
If UCase(Left(u,7))="HTTP://"
ProcedureReturn StringField(u,3,"/")
Else
ProcedureReturn StringField(u,1,"/")
EndIf
EndProcedure
Procedure.s URLResourcePart(u.s)
Protected p.l
If FindString(u,".",1)=0: ProcedureReturn "": EndIf
For p=Len(u) To 1 Step -1
If Mid(u, p, 1)="/"
Break
EndIf
Next
ProcedureReturn Right(u, Len(u)-p)
EndProcedure
Procedure.s URLPathPart(u.s)
Protected r.s, tl.l, tr.l
tl=0: tr=0
If UCase(Left(u,7))="HTTP://": tl=8: EndIf
tl+Len(URLHostPart(u))
tr=Len(URLResourcePart(u))
ProcedureReturn Mid(u, tl, Len(u)-tl-tr)
EndProcedure
URL's don't have to be HTTP AFAIK, that just designates the protocol used to get the resource. Also, you'd maybe want something to extract the username, password and port (or skip them).dmoc wrote:"HTTP://"
Code: Select all
Procedure.s URLProtoPart(u.s)
Protected p.l
p = FindString(u,"://",1)
If p
ProcedureReturn Left(u,p-1)
Else
ProcedureReturn ""
EndIf
EndProcedure
Procedure.s URLHostPart(u.s)
If FindString(u,"://",1)
ProcedureReturn StringField(u,3,"/")
Else
ProcedureReturn StringField(u,1,"/")
EndIf
EndProcedure
Procedure.s URLResourcePart(u.s)
Protected r.s, p.l
If FindString(u,".",1)=0: ProcedureReturn "": EndIf
For p=Len(u) To 1 Step -1
If Mid(u, p, 1)="/"
Break
EndIf
Next
ProcedureReturn Right(u, Len(u)-p)
EndProcedure
Procedure.s URLPathPart(u.s)
Protected r.s, tl.l, tr.l
tl=0: tr=0
If UCase(Left(u,7))="HTTP://": tl=8: EndIf
tl+Len(URLHostPart(u))
tr=Len(URLResourcePart(u))
ProcedureReturn Mid(u, tl, Len(u)-tl-tr)
EndProcedure