Getting GUID

  1. 4 years ago

    Roberto C

    8 Jan 2015 Pre-Release Testers, Xojo Pro 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
        db.Close
      End If
    End Function

    Perhaps it might be helpful to someone else :)

    Rob

  2. Oliver O

    8 Jan 2015 Pre-Release Testers, Xojo Pro https://udemy.seminar.pro

    http://forums.realsoftware.com/viewtopic.php?f=1&t=44203&start=13

  3. John H

    9 Jan 2015 Pre-Release Testers Planet earth
    Edited 4 years ago

    An online GUID (UID) generator. https://www.guidgenerator.com/

    Info: http://en.wikipedia.org/wiki/Globally_unique_identifier

    Seems also to be a version 5 Info: http://en.wikipedia.org/wiki/Universally_unique_identifier

  4. 5 weeks ago

    Robert B

    Mar 13 Pre-Release 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 = GUID.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

    Mar 13 Pre-Release Testers, Xojo Pro, XDC Speakers Germany
    Edited 5 weeks ago

    Why not make one in xojo directly?

    Or use UUIDMBS class in MBS Plugin?

  6. Kem T

    Mar 13 Pre-Release Testers, Xojo Pro, XDC Speakers New York

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

  7. Robert B

    Mar 15 Pre-Release Testers, Xojo Pro Cincinnati, Ohio

    I'm accessing a database (not built by me) with tens of millions of rows...and for any given row...one 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: guidObject.date --- 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

    Mar 15 Pre-Release Testers, Xojo Pro Enjoying Whistler BC

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

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

    ok spaghetti whipped at the very least :P

or Sign Up to reply!