Results 1 to 6 of 6

Thread: Random help.

  1. #1
    Join Date
    Jan 2007
    Posts
    834
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default Random help.

    I need to pick a random number from 1-28.

    I could use
    SCAR Code:
    Case Random(27) of
    0:1
    1:2
    2:3
    3:4
    4:5
    5:6
    6:Stupid and boring
    end;

    Anything more professional i could use?
    Last edited by Mr. Doctor; 10-31-2009 at 10:16 PM.

  2. #2
    Join Date
    Oct 2009
    Location
    Melb, Australia
    Posts
    179
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    You don't have to number every case, unless you have 28 things to be done.
    Also note that Random() starts from 0, so you are missing case 0, which will be a problem if nothing is assigned to 0?
    (Simple fix: Case (1+Random28) of)

    I don't really know what you're trying to do, but I assume it's an anti-ban procedure and which I don't see any better way to do it.

  3. #3
    Join Date
    Jan 2007
    Posts
    834
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Pick a random number with a range from 1-28. Its use is confidential.

  4. #4
    Join Date
    Oct 2009
    Location
    Melb, Australia
    Posts
    179
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

  5. #5
    Join Date
    Oct 2009
    Location
    Stockton, CA
    Posts
    2,040
    Mentioned
    0 Post(s)
    Quoted
    1 Post(s)

    Default

    SCAR Code:
    Writeln(IntToStr(RandomRange(1, 28)));
    I really don't know what you are trying to do because it's as simple as using one of two procedures.
    PHP Code:
    function Random(RangeInteger): Integer;
    Returns random 0 <= number RangeRandom(5will return any of values 01234. Random(5) + 1 will return values 1..5.

    function 
    RandomRange(FromToInteger): Integer;
    Returns a random value between From and To
    Join the IRC! irc.rizon.net:6667/srl | SQLite (0.99rc3+) | SRL Doc | Simba Doc | Extra Simba Libraries (openSSL & sqlite3)
    Quote Originally Posted by #srl
    10:45 < Toter> daphil when can get sex anyday I want
    10:45 < Toter> he is always on #SRL
    "A programmer is just a tool which converts caffeine into code"

  6. #6
    Join Date
    Jan 2007
    Posts
    834
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    I'll use randomrange. Thanks guys.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •