[Gambas-user] Is there in Gambas a UUID implementation?

Martín mbelmonte at belmotek.net
Sun May 14 22:52:05 CEST 2023


El 12/5/23 a las 13:20, vuott--- via User escribió:
> Maybe....
> Library "libc:6"

It works.

' Gambas class file

Export

Library "libc:6"

' void srand (unsigned int __seed)
' Seed the random number generator with the given number.
'Private Extern srand(__seed As Integer)

' int rand (void)
' Return a random integer between 0 and RAND_MAX inclusive.
Private Extern rand_C() As Integer Exec "rand"

Static Public Sub Gen() As String

   Dim i As Integer
   Dim iRan As New Integer[]

   iRan.Clear

   For i = 0 To 5
     iRan.Add((Lsl(rand_C() And &03, 30)) Or (Lsl(rand_C() And &7fff, 
15)) Or (rand_C() And &7fff))
   Next

   Return Hex(iRan[0], 8) & "-" & Hex(iRan[1] And &ffff&, 4) & "-" & 
Hex((iRan[2] And &0fff) Or &4000, 4) & "-" & Hex((iRan[3] And &3fff) + 
&8000, 4) & "-" & Hex(iRan[4] And &ffff&, 4) & Hex(iRan[5], 8)

End


Thanks Vuott



More information about the User mailing list