udfPathUndecorate
str udfPathUndecorate (str)
;------------------------------------------------------------------------------------------------------------------------------------------
#DefineFunction udfPathUndecorate (strPathStr)
intMAX_PATH = 260
hdlBB = BinaryAlloc (intMAX_PATH)
BinaryPokeStr (hdlBB, 0, strPathStr)
DllCall (StrCat (DirWindows (1), "SHLWAPI.DLL"), long:"PathUndecorateA", lpbinary:hdlBB)
strPathStr = BinaryPeekStr (hdlBB, 0, intMAX_PATH)
hdlBB = BinaryFree(hdlBB)
Return strPathStr
;..........................................................................................................................................
; This UDF "udfPathUndecorate" removes the decoration from a path string.
; A decoration consists of a pair of square brackets with one or more digits in between,
; inserted immediately after the base name and before the file name extension.
;
; The following table illustrates how strings are modified by PathUndecorate.
; Initial String       Undecorated String
; C:\Path\File[5].txt  C:\Path\File.txt
; C:\Path\File[12]     C:\Path\File
; C:\Path\File.txt     C:\Path\File.txt
; C:\Path\[3].txt      C:\Path\[3].txt
;
; Requires minimum Version 5.00 of SHLWAPI.DLL
;
;..........................................................................................................................................
; Detlev Dalitz.20010827
;..........................................................................................................................................
#EndFunction
;------------------------------------------------------------------------------------------------------------------------------------------


; Test.

strPathStr1 = "C:\Path\File[5].txt"            ; ==> "C:\Path\File.txt"
strPathStr2 = "C:\Path\File[12]"               ; ==> "C:\Path\File"
strPathStr3 = "C:\Path\File.txt"               ; ==> "C:\Path\File.txt"
strPathStr4 = "C:\Path\[3].txt"                ; ==> "C:\Path\[3].txt"
strPathStr5 = "C:\Path\777[7].File(1)[3].txt"  ; ==> "C:\Path\777[7].File(1).txt"

strMsgTitle = "Demo:  udfPathUndecorate (strPathStr)"
strMsgText = ""
strMsgText = StrCat (strMsgText, strPathStr1, @LF, udfPathUndecorate (strPathStr1), @LF, @LF)
strMsgText = StrCat (strMsgText, strPathStr2, @LF, udfPathUndecorate (strPathStr2), @LF, @LF)
strMsgText = StrCat (strMsgText, strPathStr3, @LF, udfPathUndecorate (strPathStr3), @LF, @LF)
strMsgText = StrCat (strMsgText, strPathStr4, @LF, udfPathUndecorate (strPathStr4), @LF, @LF)
strMsgText = StrCat (strMsgText, strPathStr5, @LF, udfPathUndecorate (strPathStr5), @LF, @LF)

Message (strMsgTitle, strMsgText)

Exit
;------------------------------------------------------------------------------------------------------------------------------------------