• 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: Get Random number?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Get Random number?


  • Subject: Re: Get Random number?
  • From: "Mark J. Reed" <email@hidden>
  • Date: Tue, 14 Aug 2007 17:52:21 -0400

Sorry, my answer was incomplete.

> set randomNumber to do shell script "echo $RANDOM";

That gets you randomNumber as a string, which isn't that useful.

set randomNumber to do shell script "echo $RANDOM" as integer;

will get you a numeric value you can then manipulate in the ways I listed.


> which will get you a random integer uniformly distributed between 0
> and 32767, inclusive.  You can then take the remainder with respect to
> some integer (if you're looking to simulate a dice roll or similar) or
> divide by 32768 to get a float in the [0,1) range.


--
Mark J. Reed <email@hidden>
 _______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users

This email sent to email@hidden

References: 
 >Get Random number? (From: Jakob Peterhänsel <email@hidden>)
 >Re: Get Random number? (From: "Mark J. Reed" <email@hidden>)

  • Prev by Date: Re: Get Random number?
  • Next by Date: Re: Get Random number?
  • Previous by thread: Re: Get Random number?
  • Next by thread: Re: Get Random number?
  • Index(es):
    • Date
    • Thread