PxPlus User Forum

Twitter Twitter Twitter

Author Topic: GUID generator  (Read 3505 times)

Dave Fullerton

  • Silver Member
  • ***
  • Posts: 35
    • View Profile
GUID generator
« on: December 05, 2019, 03:12:00 PM »
Hi folks:

Doing a transfer of data from PxPlus files by generating text files which will be transferred to a SQL database.  Apparently, this database requires GUID's and it makes the migration much easier if I can generate it and stick it them in the text file - especially as the GUID may reference data in a different text file.

Does anyone know of a GUID generator that works in PxPlus?

Thanks

Dave Fullerton

GordDavey

  • Member
  • **
  • Posts: 9
    • View Profile
Re: GUID generator
« Reply #1 on: December 05, 2019, 04:59:15 PM »
Dave,
If you are using Windows then the following OOP method will return new GUID's in hex and in lowercase, which is typically how they are stored, since you don't want to store the 16 binary chars that make them up as you could have field seps in the binaary values.:

   function local getGUID(guid$)
      local pGuid$, S_OK, BYTE
      SO_OK = 0, BYTE = tcb(303)
      enter pGuid$
      
      pGuid$ = dim(BYTE * 16, $00$)
      if dll("Ole32", "CoCreateGuid", pGuid$) <> S_OK pGuid$ = ""; return 0
      pGuid$ = lcs(hta(pGuid$))

      return 1
Gord Davey <gord.davey@Avexware.com>
President - Avexware Corp.
Tel: +1 (519) 835-4322

Dave Fullerton

  • Silver Member
  • ***
  • Posts: 35
    • View Profile
Re: GUID generator
« Reply #2 on: December 05, 2019, 05:38:07 PM »
Hi Gord:

Thanks for this - I'll see if I can get it to work - I'm very green with the OOP stuff.

Dave

Josh Fake

  • Member
  • **
  • Posts: 13
    • View Profile
    • Earnest & Associates
Re: GUID generator
« Reply #3 on: December 06, 2019, 11:19:09 AM »
Dave/Gord,

Also if you are using Windows, you can use the following code:

0252 def object myguid,"Scriptlet.TypeLib"
0253 guid$=mid(myguid'guid$,2,36)
0254 drop object myguid

Just another way to accomplish the same thing as Gord!

Josh

Dave Fullerton

  • Silver Member
  • ***
  • Posts: 35
    • View Profile
Re: GUID generator
« Reply #4 on: December 06, 2019, 11:40:42 AM »
Hi Josh:

That is very cool as well, and it comes out formatted, which is nice.  Add a LCS and it's exactly what I'm looking for.

Thanks

Dave