GetParentDirectory(ChildDirectory$)
A nice way to travel back up a path.
GetParentDirectory()
- the.weavster
- Addict
- Posts: 1576
- Joined: Thu Jul 03, 2003 6:53 pm
- Location: England
Re: GetParentDirectory()
I often too have ideas of adding lot of such small useful stuff, but generally such small things are not needed at language level and only adding extra work for PB team.
You can use something like following
You can use something like following
Code: Select all
; Path$ directory or file path
; RETURN: parent path from a current path or empty string if reached top
Procedure$ ParentDir (Path$)
ProcedureReturn GetPathPart(RTrim(GetPathPart(Path$), "\"))
EndProcedure
; test
Debug "'" + ParentDir(ProgramFilename()) + "' from '" + ProgramFilename() + "'"
Debug "'" + ParentDir("D:\1\") + "' from 'D:\1\'"
Debug "'" + ParentDir("D:\") + "' from 'D:\'"
Debug "'" + ParentDir("D:") + "' from 'D:'"
"W̷i̷s̷h̷i̷n̷g o̷n a s̷t̷a̷r"