GUID generator

Started by Dave Fullerton, December 05, 2019, 03:12:00 PM

Previous topic - Next topic

Dave Fullerton

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

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

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

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

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