GetRelativePath()

Summary

Converts an absolute pathname to a relative pathname.

Changes

Added to Version 2019.

Syntax

GetRelativePath(string ref_path, string path)

Argument Contents
ref_path The reference pathname
path The absolute pathname to convert to a pathname relative to ref_path

Returns

The relative pathname.

Error Codes

Error Type Meaning
Error The absolute pathname does not exist

Notes

  • The relative pathname is the portion of the absolute pathname that is not included in the reference pathname.

Examples

folder = RunMacro("G30 Tutorial Folder")
file_name = folder + "customer.dbf"
relative_path = GetRelativePath(folder, file_name)
ShowMessage("The relative pathname for " + file_name + " is " + relative_path)
result = GetRelativePath("C:\\projects", "C:\\projects\\inputs\\test")
// result = "inputs\\test"

See Also

Function Summary
CompactPath() Shortens a file's pathname to the listed length for purposes of display.
GetAbsolutePath() Converts a relative pathname to an absolute pathname.
GetLongPathName() Returns the full, long pathname for a file
GetShortPathName() Returns the short pathname for a file
IsPathAbsolute() Tests to see if the pathname is an absolute pathname
SplitPath() Splits a path and filename into its component parts