NetTalk Central

Author Topic: creating a guid using string theory  (Read 4040 times)

terryd

  • Hero Member
  • *****
  • Posts: 759
    • View Profile
    • Davcomm
    • Email
creating a guid using string theory
« on: October 23, 2013, 10:06:36 PM »
Hi Bruce
NTWS725 StringTheory191
Not really a Nettalk question but since this comes up when creating a guid using string theory in my webservers maybe you can help.

Whenever I create a new record i create a guid by calling a source procedure which contains this line:

 RETURN st.Random(16,st:Lower + st:Number)

I would expect this to create a 16 character string with a combination of lowercase and numbers
However it just seems to be returning lowercase characters
Below is an extract from a table created using this procedure
"Documentid"
"ccdgtholabhrbrna"
"mxkayecctmnzubsr"
"vsckltobkkcaqlpw"
"kgzjpagqrmeksoxf"
"ilwgxhwgnbiixzta"
 "gygmgicwejxalxdq"

Is my st.Random call correct?
Terry Davidson
Windows 10 64 bit/Windows7 64bit
Clarion 9.1.11529/Clarion10 12567
Nettalk 913
Nettalk 1015
StringTheory267/Winevent515/XFiles298/MessageBox239/Cryptonite186

Stu

  • Hero Member
  • *****
  • Posts: 510
    • View Profile
    • Email
Re: creating a guid using string theory
« Reply #1 on: October 23, 2013, 10:09:10 PM »
Hey Terry,

The st.Random() call is right (I use
Code: [Select]
st.Random(20,st:Upper+st:Lower+st:Number)).

But to get the string, you'll want to use st.GetValue(), ie

Code: [Select]
rec:GUID = st.GetValue()

At least, that's what I've got in my code.

But looking at the docs (http://capesoft.com/docs/StringTheory/StringTheory.htm#stRandom), I see that you CAN use the call.

Nice. Learn something new every day.
« Last Edit: October 23, 2013, 10:10:47 PM by Stu »
Cheers,

Stu Andrews

Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11250
    • View Profile

Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11250
    • View Profile
Re: creating a guid using string theory
« Reply #3 on: October 24, 2013, 02:20:07 AM »
I ran a test here, using that line, and I seem to get back values including digits.
Perhaps your priming is not actually using that function?
maybe put a debugview, or stop statement in there just to make sure.

cheers
Bruce


TimR

  • Newbie
  • *
  • Posts: 28
    • View Profile
Re: creating a guid using string theory
« Reply #4 on: October 24, 2013, 06:14:31 PM »
If using MSSQL you can also use this statement to generate a guid.

select newid()

Off topic a bit, but I'm hoping if I write it down I may actually remember it when I need it.

terryd

  • Hero Member
  • *****
  • Posts: 759
    • View Profile
    • Davcomm
    • Email
Re: creating a guid using string theory
« Reply #5 on: October 24, 2013, 07:14:18 PM »
Thanks Bruce, Tim
I found my issue. Previously I had coded into the priming embed point without the number attribute (before it was available). I then created the little source procedure and called it directly from the template priming tab as CreateGUID(''). Because the embed point is after the template priming point it overrode the value passed back from the source procedure.

Tim
Currently I prefer what i am doing since should I convert this app at a later stage to SQL my code wouldn't change (i.e. I wouldn't end up doing exactly what I did here ;-))
Terry Davidson
Windows 10 64 bit/Windows7 64bit
Clarion 9.1.11529/Clarion10 12567
Nettalk 913
Nettalk 1015
StringTheory267/Winevent515/XFiles298/MessageBox239/Cryptonite186