Truncate a long path with ellipsesTag(s): Powerscript


The PathCompactPathEx truncates a path to fit within a certain number of characters by replacing path components with ellipses.
[local function declaration]
FUNCTION boolean PathCompactPathEx  &
   ( REF String pszOut, string szPath, uint cchMax, long dwFlags) &
    ALIAS FOR "PathCompactPathExA" &
    LIBRARY "shlwapi.dll"


[powerscript]
String ls_longPath = &
   "C:\Applications\Netscape\Netscape8\defaults\profile\chrome"

// 30 chars max plus a null
String ls_truncatedPath = space(31)

PathCompactPathEx(ls_truncatedPath, ls_longPath, 31, 0)

MessageBox(ls_longPath, ls_truncatedPath)

/*
Output :
---------------------------
C:\Applications\Netscape\Netscape8\defaults\profile\chrome
---------------------------
C:\Applications\Nets...\chrome
---------------------------
OK   
---------------------------
*/


blog comments powered by Disqus