Page 1 of 2

How to strip characters out of uuid to use as a random seed

Posted: Mon Jun 23, 2014 5:28 am
by shawnblc
How to strip characters out of uuid to use as a random seed? So that I'm only left with numbers, since randomseed only uses numbers.

Re: How to strip characters out of uuid to use as a random s

Posted: Mon Jun 23, 2014 5:38 am
by sefrojones
This worked for me, although I'm sure there's a fancier way to do it:

Code: Select all

on mouseUp
   put empty into tSeed
   put uuid() into tVar
   repeat with x=1 to the number of characters in tVar
      if char x of tvar is a number then 
         put char x of tvar  after tSeed
      else
         put empty into char x of tvar
            end if
      end repeat
answer tseed
   end mouseUp

Re: How to strip characters out of uuid to use as a random s

Posted: Mon Jun 23, 2014 5:42 am
by shawnblc
Thanks sefrojones. I'll give it a shot. Seems like it's doing the trick.

Re: How to strip characters out of uuid to use as a random s

Posted: Mon Jun 23, 2014 6:17 am
by sefrojones
Is there a limit to the length of a randomseed? I'm trying to use (basically) the same script as i posted above, and for some reason when I set the randomseed to tSeed, it doesn't take. Any ideas?

edit: It seems like you can't set the randomseed to any number longer than 9 digits.......

Re: How to strip characters out of uuid to use as a random s

Posted: Mon Jun 23, 2014 6:30 am
by shawnblc
sefrojones wrote:Is there a limit to the length of a randomseed? I'm trying to use (basically) the same script as i posted above, and for some reason when I set the randomseed to tSeed, it doesn't take. Any ideas?

edit: It seems like you can't set the randomseed to any number longer than 9 digits.......

I tried your script so far and threw in a random text file to see what it looked like.

Code: Select all

put empty into tSeed
       put uuid() into tVar
       repeat with x=1 to the number of characters in tVar
              if char x of tvar is a number then 
                     put char x of tvar  after tSeed
              else
                     put empty into char x of tvar
                    end if
          end repeat
    
## I wonder if this is even random
    put any line of URL ("http://domain.com/totalrandom.txt") into tLine1
    put tLine1 into field "fldRandom1"

Re: How to strip characters out of uuid to use as a random s

Posted: Mon Jun 23, 2014 6:31 am
by shawnblc
In the dictionary they have an example with a 7 digit number, but don't mention a limit.

Re: How to strip characters out of uuid to use as a random s

Posted: Mon Jun 23, 2014 6:32 am
by sefrojones
I think I've got this figured out, here's what I've got now, and it seems to be working great.

Code: Select all

on mouseUp
   put uuid() into tVar
   repeat with x=1 to the number of characters in tVar
      if char x of tvar is a number then 
         put char x of tvar  after tSeed
         if the number of chars of tSeed >=9 then exit repeat
            end if
         end repeat
         replace space with empty in tSeed
         set the randomseed to tSeed
         Answer "randomseed:" && the randomseed&cr& "random:"&&random(100) & cr & "uuid:"&&tvar
end mouseUp
If the randomseed is longer than 9 digits, it will continually arrive at the same "random" number
edit: or so it seems to me

Re: How to strip characters out of uuid to use as a random s

Posted: Mon Jun 23, 2014 6:36 am
by shawnblc
sefrojones wrote:I think I've got this figured out, here's what I've got now, and it seems to be working great.

Code: Select all

on mouseUp
   put uuid() into tVar
   repeat with x=1 to the number of characters in tVar
      if char x of tvar is a number then 
         put char x of tvar  after tSeed
         if the number of chars of tSeed >=9 then exit repeat
            end if
         end repeat
         replace space with empty in tSeed
         set the randomseed to tSeed
         Answer "randomseed:" && the randomseed&cr& "random:"&&random(100) & cr & "uuid:"&&tvar
end mouseUp
If the randomseed is longer than 9 digits, it will continually arrive at the same "random" number
edit: or so it seems to me


Looks good. Gonna play with it. Like a kid with a new toy. lol

Re: How to strip characters out of uuid to use as a random s

Posted: Mon Jun 23, 2014 6:44 am
by shawnblc
sefrojones wrote:I think I've got this figured out, here's what I've got now, and it seems to be working great.

Code: Select all

on mouseUp
   put uuid() into tVar
   repeat with x=1 to the number of characters in tVar
      if char x of tvar is a number then 
         put char x of tvar  after tSeed
         if the number of chars of tSeed >=9 then exit repeat
            end if
         end repeat
         replace space with empty in tSeed
         set the randomseed to tSeed
         Answer "randomseed:" && the randomseed&cr& "random:"&&random(100) & cr & "uuid:"&&tvar
end mouseUp
If the randomseed is longer than 9 digits, it will continually arrive at the same "random" number
edit: or so it seems to me

Not so random for me. When I close and remove from memory and close out LC. Restart, I get the same results.

Re: How to strip characters out of uuid to use as a random s

Posted: Mon Jun 23, 2014 6:47 am
by sefrojones
shawnblc wrote:

Looks good. Gonna play with it. Like a kid with a new toy. lol
Same here, I had never heard of uuid() until Simon mentioned it in your other post :D

--Sefro

Re: How to strip characters out of uuid to use as a random s

Posted: Mon Jun 23, 2014 6:53 am
by shawnblc
sefrojones wrote:
shawnblc wrote:

Looks good. Gonna play with it. Like a kid with a new toy. lol
Same here, I had never hard of uuid() until Simon mentioned it in your other post :D

--Sefro
Know whatcha mean, I've heard of uuid's and namespaces (I definitely don't understand them), but I don't do this for a living like some guys on here. Just a hobby. With any luck one day I'll make something a few find useful and they might just be willing to pay for it. :)

I was getting better results with what you had the first time around. Seemed a lot more random, even when I went from reading lines from a 10,000 line file to one with less than 20 lines.

Re: How to strip characters out of uuid to use as a random s

Posted: Mon Jun 23, 2014 7:03 am
by sefrojones
shawnblc wrote: I was getting better results with what you had the first time around. Seemed a lot more random, even when I went from reading lines from a 10,000 line file to one with less than 20 lines.
That's weird, when i try to use my first script it works to seperate the numbers form the UUID but when I try to set the randomseed to Tseed, It will only use tSeed as the randomseed if it is less than 9 digits. If it is more than 9 digits it will not throw an error, but the randomseed is set to a different number (the same one every time), and random(100) will give the same result every time. When i set it to only use the first 9 digits of tSeed, it seemingly works fine......This is on Ubuntu 14.04 (which I am very new to) I will probably play around with this a bit more in windows 7 tomorrow.

--Sefro

Re: How to strip characters out of uuid to use as a random s

Posted: Mon Jun 23, 2014 2:06 pm
by [-hh]
..........

Re: How to strip characters out of uuid to use as a random s

Posted: Mon Jun 23, 2014 6:43 pm
by FourthWorld
@ shawnblc: The randomSeed property can be useful in cases where you want psuedorandomization across a repeatable series, but it not generally regarded as being able to increase the breadth of distribution for simulating true randomness. As Hermann suggested, the randseed setting the engine does at the beginning of each session is generally viewed as sufficient.

What problems did you encounter with the default randomseed?

Re: How to strip characters out of uuid to use as a random s

Posted: Tue Jun 24, 2014 5:08 am
by shawnblc
FourthWorld wrote: What problems did you encounter with the default randomseed?
When using randsomseed, closing the program & removing from memory, then restarting the stack I'd get the same repeated line using randomseed or using any line. Both on OSX 10.93 and Windows 7 (vmware). Anytime my stack is called I'd like it truly random. Not a repeat of the same sequence.