Hello everyone,
Sorry to re-open an old thread. This is my version of Mistrel's original code. I needed this for my 3D game project.
Code:
; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
; Project name : Cross-platform UUID generator
; File Name : UUID - Module.pb
; File version: 1.0.0
; Programming : OK
; Programmed by : StarBootics
; Date : 22-01-2019
; Last Update : 22-01-2019
; PureBasic code : V5.70 LTS
; Platform : Windows, Linux, MacOS X
; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
; Programming notes
;
; Based on Mistrel's original code.
; See here : https://www.purebasic.fr/english/viewtopic.php?f=12&t=38011
;
; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
DeclareModule UUID
Declare.s Make(Wrap_With_Brackets.b = #False)
EndDeclareModule
Module UUID
Procedure.s Make(Wrap_With_Brackets.b = #False)
For Index = 0 To 15
If Index = 7
Byte.a = 64 + Random(15)
ElseIf Index = 9
Byte = 128 + Random(63)
Else
Byte = Random(255)
EndIf
If Index = 4 Or Index = 6 Or Index = 8 Or Index = 10
UUID_String.s + "-"
EndIf
UUID_String + RSet(Hex(Byte, #PB_Ascii), 2, "0")
Next
If Wrap_With_Brackets = #True
UUID_String = "{" + UUID_String + "}"
EndIf
ProcedureReturn UUID_String
EndProcedure
EndModule
CompilerIf #PB_Compiler_IsMainFile
Macro AddElementEx(ListName, Element)
AddElement(ListName)
ListName = Element
EndMacro
NewList UUID.s()
For index = 0 To 499
AddElementEx(UUID(), UUID::Make())
Next
SortList(UUID(), #PB_Sort_Ascending)
ForEach UUID()
Debug UUID()
Next
CompilerEndIf
; <<<<<<<<<<<<<<<<<<<<<<<
; <<<<< END OF FILE <<<<<
; <<<<<<<<<<<<<<<<<<<<<<<
Best regards
StarBootics