I couldn’t sleep. Also I don’t know how to deal with formatting this because of the apostrophes and I don’t care that much
Function CreateUUIDv4$ ()
’ this routine generates about 23 guids per second at 4.77 MHz
' define a UUID string template
Dim result As String * 36
result = "00000000-0000-0000-0000-000000000000"
' 123456789012345678901234567890123456
Dim substring$
Dim index%, offset%
' enumerate the indices where we should insert values
For index% = 1 To 33 Step 4
' skip over the separators
If index% = 9 Or index% = 14 Or index% = 19 Or index% = 24 Then
index% = index% + 1
End If
' generate a value from 0x0000 to 0xFFFF
substring$ = Hex$(Int((&HFFFF& - 0 + 1) * Rnd + 0))
' add an offset that permits leading zeroes if the hex representation
' of the value to insert is less than 4 characters
offset% = 4 - Len(substring$)
' insert the substring at the specified location
Mid$(result, index% + offset%) = substring$
Next
' version 4 (random data)
Mid$(result, 15) = "4"
' variant DCE 1.1, ISO/IEC 11578:1996 (0x1000 - 0x1011)
Mid$(result, 20) = Hex$(Int(Rnd * 4 + 8))
CreateUUIDv4$ = result
End Function
You must log in or # to comment.
deleted by creator