Getting GUID

  1. 5 years ago

    Calvi T

    8 Jan 2015 Testers Europe (Milan, Italy)

    I had problems in getting GUID on Mac, Windows and Linux…
    I found a solution:

    Function Method_Generate_GUID() As String
      Dim db As New SQLiteDatabase
      Dim Sql_instruction As String= "select hex( randomblob(4)) " _
      + "|| '-' || hex( randomblob(2)) " _
      + "|| '-' || '4' || substr( hex( randomblob(2)), 2) " _
      + "|| '-' || substr('AB89', 1 + (abs(random()) % 4) , 1) " _
      + "|| substr(hex(randomblob(2)), 2) " _
      + "|| '-' || hex(randomblob(6)) AS GUID"
      If db.Connect Then
        Dim GUID As String = db.SQLSelect(Sql_instruction).Field("GUID")
        Return  GUID
      End If
    End Function

    Perhaps it might be helpful to someone else :)


  2. Oliver O

    8 Jan 2015 Testers, Xojo Pro

  3. John H

    9 Jan 2015 Planet earth
    Edited 5 years ago

    An online GUID (UID) generator.


    Seems also to be a version 5 Info:

  4. last year

    Robert B

    13 Mar 2019 Testers, Xojo Pro Cincinnati, Ohio

    Not sure if this is "fair" adding a comment to a 4 year old post -- but it's a little dissapointing there is no built in class for handling GUID/UUID. I see where people can generate them, but other "handling" operations for different versions of GUIDS are also "some assembly required". I need to get the TIMESTAMP out of a Version 1 (date/time based GUID). I know the algorithm for generating that part of the GUID from a Mac/Linux EPOCH date. -- this can be reversed so that the GUID can reveal the EPOCH date. -- but there is no built in class. Bummer. in some environments you can just (Pseudo) Dim myGUID as new GUID. GUID.text = "b54adc00-67f9-11d9-9669-0800200c9a66" Dim myDate as Date = -- Y'all are gonna make me code to accomplish this. People often need a GUID and it just strikes me as off that each and every person needs to learn the design and how to roll their own GUID class. This kind of lower level stuff pulls people away from "the big picture". So happy that so many on the board here are willing to share what they've learned.

  5. Christian S

    13 Mar 2019 Testers, Xojo Pro, XDC Speakers, Third Party Store Germany
    Edited last year

    Why not make one in xojo directly?

    Or use UUIDMBS class in MBS Plugin?

  6. Kem T

    13 Mar 2019 Testers, Xojo Pro, XDC Speakers, MVP Connecticut

    FYI, my M_Crypto , M_Text , and M_String modules all have this built in using system calls.

  7. Robert B

    15 Mar 2019 Testers, Xojo Pro Cincinnati, Ohio

    I'm accessing a database (not built by me) with tens of millions of rows...and for any given of the things I need is a "date". Turns out that the original database designers opted to include multiple dates within the database...but not the date I need. That particular date is encapsulated in the Version1 GUID. as the number of 100 nanosecond intervals since Oct 15th 1582 -- Seriously? Ok...well that's the official creation date of the Gregorian calendar. Anyway...once I discovered where the date I need was "stored" (embedded in the record ID) -- there is a "built in method" on a GUID object in .Net to fetch it with complicated syntax like: --- alas the implementation of a GUID class in Xojo is left to the programmers (or enterprising 3rd parties like Christian) to figure out. Ok, so really it's not that complicated...a little bit of string manipulation and hex to Int64 with a constant adjustment for jan 1st 1900 and no problem. I'm just whining I had to do it. :-P. I think Christians class will generate Random type GUIDs (probably Type 4 or something) -- but I didn't have a choice over what kind of I needed to work with and the the glorious Idea of embedding a critical date field in the GUID.

  8. Norman P

    15 Mar 2019 Testers, Xojo Pro outside admiring the sunshine,...

    bad bad bad bad bad ... stuff like that always comes back to bite you in the !@#$%

    the dba who designed that should be shot
    and left out in the desert for the vultures

    ok spaghetti whipped at the very least :P

or Sign Up to reply!