udfPathGetCharInfo
arr udfPathGetCharInfo (str)
;-----------------------------------------------------------------------------------------------------------------------------------------
#DefineFunction udfPathGetCharInfo (strString)
If strString == "" Then Return ""
hdlShlwapi = DllLoad ("SHLWAPI.DLL")
GCT_INVALID = 0
GCT_LFNCHAR = 1
GCT_SHORTCHAR = 2
GCT_WILD = 4
GCT_SEPARATOR = 8
strDelimProp = " "
intLen = StrLen (strString)
intLast = intLen - 1
arrOut = ArrDimension (intLen, 3)
For intI = 0 To intLast
   strChar = StrSub (strString, intI + 1, 1)
   intChar = Char2Num (strChar)
   intResult = DllCall (hdlShlwapi, long : "PathGetCharTypeA", word : intChar)
   strProp = ""
   Switch @TRUE
   Case (intResult & GCT_SEPARATOR) == GCT_SEPARATOR ; Char is path separator.
      strProp = strProp : strDelimProp : "SEP"
      Continue
   Case (intResult & GCT_WILD) == GCT_WILD           ; Char is wildcard.
      strProp = strProp : strDelimProp : "WLD"
      Continue
   Case (intResult & GCT_SHORTCHAR) == GCT_SHORTCHAR ; Char is valid for DOS.
      strProp = strProp : strDelimProp : "SFN"
      Continue
   Case (intResult & GCT_LFNCHAR) == GCT_LFNCHAR     ; Char is valid for LFN.
      strProp = strProp : strDelimProp : "LFN"
      Continue
   Case intResult == GCT_INVALID                     ; Char is invalid.
      strProp = strProp : strDelimProp : "INV"
      Continue
   EndSwitch
   strProp = StrSub (strProp, 2, -1)
   arrOut [intI, 0] = strChar
   arrOut [intI, 1] = intChar
   arrOut [intI, 2] = strProp
Next
hdlShlwapi = DllFree (hdlShlwapi)
Return arrOut
;......................................................................................................................
; This UDF "udfPathGetCharInfo" determines the type of each character of a given string in relation to a path.
; The function returns a dim-2 array with each row containing three properties related to one character.
; The character itself, the collating sequence number of the character, the type of character. e. g. ["\"|92|"SEP"].
;
; Used abbreviations:
; INV = GCT_INVALID   The character is not valid in a path.
; LFN = GCT_LFNCHAR   The character is valid in a long file name.
; SFN = GCT_SHORTCHAR The character is valid in a short (8.3) file name.
; WLD = GCT_WILD      The character is a wildcard character.
; SEP = GCT_SEPARATOR The character is a path separator.
;
; Detlev Dalitz.20090705.
;......................................................................................................................
#EndFunction
;-----------------------------------------------------------------------------------------------------------------------------------------


; Test.

strTest = '\/:.,;*?"<>|aA~' : Num2Char (127) : Num2Char (128) : Num2Char (27) : @TAB : @CRLF

arrResult = udfPathGetCharInfo (strTest)

strFileTemp = FileCreateTemp ("WBT")
intBytesWritten = ArrayFilePutCSV (strFileTemp, arrResult, @TAB, @TRUE, 2)
strResult = FileGet (strFileTemp)
blnResult = FileDelete (strFileTemp)
ClipPut (strResult)
Message ("Demo: udfPathGetCharInfo (strString)", strResult)

Exit

;------------------------------------------------------------------------------------------------------------------------------------------
; strTest = '\/:.,;*?"<>|aA~' : Num2Char (127) : Num2Char (128) : Num2Char (27) : @TAB : @CRLF
;
;   \    92    SEP
;   /    47    INV
;   :    58    SEP
;   .    46    SFN LFN
;   ,    44    LFN
;   ;    59    LFN
;   *    42    WLD
;   ?    63    WLD
;   "    34    INV
;   <    60    INV
;   >    62    INV
;   |    124   INV
;   a    97    SFN LFN
;   A    65    SFN LFN
;   ~    126   SFN LFN
;       127   SFN LFN
;   €    128   SFN LFN
;        27    INV
;        9     INV
;        13    INV
;        10    INV
;------------------------------------------------------------------------------------------------------------------------------------------