CompactPath()

Summary

Shortens a file's pathname to the listed length for purposes of display.

Changes

Added to Version 2019.

Syntax

CompactPath(string path, integer length)

Argument Contents
path Full file pathname of a file
length Shortened string length

Returns

The pathname no longer than length.

Notes

  • CompactPath() replaces a part of the pathname with an ellipsis so that it can be used, for example, to get a short display name that fits into a smaller space in a dialog box.

  • Unlike GetShortPathName(), CompactPath() returns a pathname that cannot be used to refer to the file.

Examples

folder = RunMacro("G30 Tutorial Folder")
file_name = folder + "customer.dbf"
compact_name = CompactPath(file_name, 20)
ShowMessage("The compact pathname for " + file_name + " is " + compact_name)
result = CompactPath("C:\\this\\is\\a\\long\\path.exe", 10)
// result = "...\\path.exe"

See Also

Function Summary
GetAbsolutePath() Converts a relative pathname to an absolute pathname
GetLongPathName() Returns the full, long pathname for a file
GetRelativePath() Converts an absolute pathname to a relative pathname
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