• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Select some item of...
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Select some item of...


  • Subject: Re: Select some item of...
  • From: Christopher Nebel <email@hidden>
  • Date: Mon, 10 Nov 2003 16:13:54 -0800

On Nov 3, 2003, at 8:36 PM, Emmanuel wrote:

At 10:57 PM +0000 03/11/03, Peter Beentje wrote:
Yeah, I wrote all my scripts from scratch without reference until about 2 months ago, pulling myself up by my bootstraps all the way; I never worked out the syntax for seeding properly. I haven't thought of a way to combine 'random number with seed of...' and 'set x to some item of...' either; anyone care to suggest a way?

Suppose you issue one "random number with seed [current date]" (did not check the syntax) before each "some item", I suppose that this would fairly well randomize things for you?

Wouldn't work -- "some" and "random number" use completely independent mechanisms. There is no control provided over the seed used for "some".

I think I've found the problem: Peter probably somehow changed his script to now use Unicode text (or perhaps Unicode is being forced upon him). It seems that "some" for Unicode text uses a different RNG than other parts of AppleScript (rand(3), to be precise; everyone else uses randomx), and doesn't bother to seed it at all, so you'll always get the same sequence. This looks like it's always been the case. Workaround: coerce to string and get some paragraph of that, or use "random number".

Incidentally, using "random number with seed current date" works, but should be fairly unnecessary, since "random number" will seed itself from the system clock if you don't provide an explicit seed. However, the clock it uses only changes every 60th of a second, so if you hit it fast enough, you'll get identical sequences.


--Chris Nebel
AppleScript Engineering
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.

References: 
 >Select some item of... (From: Peter Beentje <email@hidden>)
 >Re: Select some item of... (From: Emmanuel <email@hidden>)
 >Re: Select some item of... (From: Peter Beentje <email@hidden>)
 >Re: Select some item of... (From: Emmanuel <email@hidden>)

  • Prev by Date: Re: Panther: AppleScript 1.9.2 Release Notes
  • Next by Date: Re: applescript-users digest, Vol 3 #2146,#2145,#2144....
  • Previous by thread: Re: Select some item of...
  • Next by thread: Help with Project builder
  • Index(es):
    • Date
    • Thread