DirectoryUp

Function DirectoryUp(dirpath: String, [levels: Integer=1]) : String
Returns a path as a string

This function makes it easy to manipulate file paths. Specify levels to transverse up more than one level.

Example:

Program
  Uses
basilisk, pure2d

Begin
  InitBasilisk(TRUE)
  OpenScreen(640,480,32,FALSE,COB_SHOWCLOSE+COB_SHOWBORDER)
  
  Text(10,10,"C:\myfolder\another\yetanother\myfile.txt -> "+DirectoryUp("C:\myfolder\another\yetanother\myfile.txt"))
  Text(10,30,"C:\myfolder\another\yetanother\myfile.txt (2) -> "+DirectoryUp("C:\myfolder\another\yetanother\myfile.txt",2))
  Text(10,50,"C:\myfolder\another\yetanother\ -> "+DirectoryUp("C:\myfolder\another\yetanother\"))
  Text(10,70,"C:\myfolder\another\yetanother\ (3) -> "+DirectoryUp("C:\myfolder\another\yetanother\",3))
  Text(10,90,"http://www.socoder.net/index.php -> "+DirectoryUp("http://www.socoder.net/index.php"))
  
  While Not ExitRequested
   Flip
   Pause
(2)
  Wend
     
End