Basic Univers
; Author : Thyphoon (edit by Dr.Dri)
; Date   : 28/04/07



Procedure.s RelativePath(Path.s, FromPath.s = "")
  Protected l.w, c.w, NewPath.s
  Newpath.s = ""
  c = 0
 
  If Not FromPath
    FromPath = GetCurrentDirectory()
  EndIf
 
  If Left(Path, 1) <> Left(FromPath, 1)
    ProcedureReturn Path
  EndIf
 
  For l = Len(FromPath) To 1 Step - 1
 
    If Mid(FromPath, l, 1)="\"
       c + 1
   
       If FindString(Path, Left(FromPath, l), 1)
         Break
       EndIf
 
    EndIf
 
  Next l
 
  For z = 1 To c - 1
    Newpath +"..\"
  Next
 
  Newpath + Right(Path, Len(Path)- l)
 
  ProcedureReturn NewPath
EndProcedure
 
 File$ = OpenFileRequester("Choose a File", FichierParDefaut$, Filtre$, Filtre)
While File$
       Debug "Absolute Path:" + File$
       Debug "Relative Path:" + RelativePath(File$)
File$ = NextSelectedFileName()
Wend