udfGUIDToStr
str udfGUIDToStr (int, str)
Download: COM object CSGUID.dll as zip package
;------------------------------------------------------------------------------------------------------------------------------------------
#DefineFunction udfGUIDToStr (intCount, strRemoveChars)
strFileDll = "CSGUID.DLL"
strFileDllPath = FileLocate (strFileDll)
Terminate (strFileDllPath == "", "Terminated.", strFileDll : @LF : "not found.")
intResult = DllCall (strFileDllPath, long : "DllRegisterServer") ; Register the scripting component.
Terminate (intResult != 0, "Terminated.", strFileDllPath : @LF : "not registered.")

strList = ""
objGUID = ObjectCreate ("CSGUID.GUIDGenerator")
For intItem = 1 To intCount
   strList = ItemInsert (objGUID.CreateGUID(strRemoveChars), -1, strList, @TAB)
Next
objGUID = 0

intResult = DllCall (strFileDll, long : "DllUnregisterServer") ; Unregister the scripting component.
Terminate (intResult != 0, "Terminated.", strFileDllPath : @LF : "not unregistered.")
Return strList
;..........................................................................................................................................
; This UDF "udfGuidToStr" creates a global unique identifier (GUID), or more as given by the parameter intCount.
; The format of the GUID string can be adjusted by the parameter strFormat.
;
; Parameter:
; intCount       = n      ... Create a string list of n-count GUID strings.
; strRemoveChars = ""     ... Standard GUID format with special characters inserted for better human readability.
; strRemoveChars = "{-}"  ... Set of Characters to remove from GUID string.
;..........................................................................................................................................
;
; This function uses the scripting component "CSGUID.GUIDGenerator" developed by "(c)1999 Control-Shift Inc."
;
; Library: CSGUID
; Description: Control-Shift - GUID Generator
; coclass GUIDGenerator
;
; <reference guid="{1C57E761-551D-11D3-9C51-006097C3EAE4}" version="3.0" />
;
; Function CreateGUID([strRemoveChars As String = "{}-"]) As String
;..........................................................................................................................................
;
; Microsoft has defined letters for identifying the format of a GUID string.
;
; Specifier  Format of the input parameter
;
;     N :    00000000000000000000000000000000
;            32 digits.
;
;     D :    00000000-0000-0000-0000-000000000000
;            32 digits separated by hyphens (36 characters).
;
;     B :    {00000000-0000-0000-0000-000000000000}
;            32 digits separated by hyphens, enclosed in curly brackets (38 characters).
;
;     P :    (00000000-0000-0000-0000-000000000000)
;            32 digits separated by hyphens, enclosed in round brackets (38 characters).
;
;     X :    {0x00000000,0x0000,0x0000,{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}} (68 characters).
;            Four hexadecimal values enclosed in braces, where the fourth value is a
;            subset of eight hexadecimal values that is also enclosed in braces.
;..........................................................................................................................................
;
; With the fitting characters in parameter strRemoveChars the function can build the following string formats.
; The formats N, D, P are valid for intCount >= 1. The formats P, X are only valid for intCount = 1.
;
;     N :    udfGuidToStr (1, "{-}") ; 32 digits.
;
;     D :    udfGuidToStr (1, "{}")  ; 32 digits separated by hyphens (36 characters).
;
;     B :    udfGuidToStr (1, "")    ; 32 digits separated by hyphens, enclosed in curly brackets (braces) (38 characters).
;
;     P :    "(" : ItemRemove (1, ItemRemove (-1, udfGuidToStr (1, ""), "}") , "{") : ")"
;                                    ; 32 digits separated by hyphens, enclosed in round brackets (parentheses) (38 characters).
;
;     X :    strGuid = udfGuidToStr (1, "{-}")
;            strFormatX = "{0x" : StrSub (strGuid, 1, 8) : ",0x" : StrSub (strGuid, 9, 4) : ",0x" : StrSub (strGuid, 13, 4)
;            strFormatX =  strFormatX : ",{0x" : StrSub (strGuid, 17, 2) : ",0x" : StrSub (strGuid, 19, 2) : ",0x" : StrSub (strGuid, 21, 2) : ",0x" : StrSub (strGuid, 23, 2)
;            strFormatX =  strFormatX : ",0x" : StrSub (strGuid, 25, 2) : ",0x" : StrSub (strGuid, 27, 2) : ",0x" : StrSub (strGuid, 29, 2) : ",0x" : StrSub (strGuid, 31, 2) : "}}"
;                                    ; Four hexadecimal values enclosed in braces, where the fourth value is a
;                                    ; subset of eight hexadecimal values that is also enclosed in braces.
;
;..........................................................................................................................................
; Detlev Dalitz.20030119.20100510.20101008.
;..........................................................................................................................................
#EndFunction
;------------------------------------------------------------------------------------------------------------------------------------------


; Test.

DirChange (DirScript ())
IntControl (28, 1, 0, 0, 0) ; Selects system font used in list boxes.


; Available Formats.

strFormatN = udfGUIDToStr (1, "{-}") ; 32 digits.

strFormatD = udfGUIDToStr (1, "{}")  ; 32 digits separated by hyphens (36 characters).

strFormatB = udfGUIDToStr (1, "")    ; 32 digits separated by hyphens, enclosed in curly brackets (braces) (38 characters).

strFormatP = "(" : ItemRemove (1, ItemRemove (-1, udfGUIDToStr (1, ""), "}"), "{") : ")" ; ... round brackets (parentheses) (38 characters).

strGuid = udfGUIDToStr (1, "{-}")
strFormatX = "{0x" : StrSub (strGuid, 1, 8) : ",0x" : StrSub (strGuid, 9, 4) : ",0x" : StrSub (strGuid, 13, 4) : ",{0x" : StrSub (strGuid, 17, 2) : ",0x" : StrSub (strGuid, 19, 2) : ",0x" : StrSub (strGuid, 21, 2) : ",0x" : StrSub (strGuid, 23, 2) : ",0x" : StrSub (strGuid, 25, 2) : ",0x" : StrSub (strGuid, 27, 2) : ",0x" : StrSub (strGuid, 29, 2) : ",0x" : StrSub (strGuid, 31, 2) : "}}"

; Display GUID strings.
strGuidList = strFormatN
strGuidList = strGuidList : @TAB : strFormatB
strGuidList = strGuidList : @TAB : strFormatD
strGuidList = strGuidList : @TAB : strFormatP
strGuidList = strGuidList : @TAB : strFormatX
IntControl (63, 200, 200, 800, 800)  ; Sets the window coordinates for the dialog box.
AskItemlist ('Demo|udfGuidToStr (intCount, strRemoveChars)', strGuidList, @TAB, @UNSORTED, @SINGLE)    ; Including all delimiters (Format B).


; Lists.

intCount = 100

strGuidList = udfGUIDToStr (intCount, "")
IntControl (63, 200, 200, 800, 800)  ; Sets the window coordinates for the dialog box.
AskItemlist ('Demo|udfGuidToStr (intCount, "")', strGuidList, @TAB, @UNSORTED, @SINGLE)     ; Including all delimiters (Format B).

strGuidList = udfGUIDToStr (intCount, "{}")
strGuidList = StrLower (strGuidList) ; Lower Case.
IntControl (63, 200, 200, 800, 800)  ; Sets the window coordinates for the dialog box.
AskItemlist ('Demo|udfGuidToStr (intCount, "{}" )', strGuidList, @TAB, @UNSORTED, @SINGLE)  ; No curly brackets, but hyphens (Format D).

strGuidList = udfGUIDToStr (intCount, "{-}")
strGuidList = StrLower (strGuidList) ; Lower Case.
IntControl (63, 200, 200, 800, 800)  ; Sets the window coordinates for the dialog box.
AskItemlist ('Demo|udfGuidToStr (intCount, "{-}" )', strGuidList, @TAB, @UNSORTED, @SINGLE) ; No brackets, no hyphens (Format N).

:CANCEL
Exit
;------------------------------------------------------------------------------------------------------------------------------------------