Results 1 to 8 of 8

Thread: random case question...

  1. #1
    Join Date
    Feb 2007
    Location
    PA, USA
    Posts
    5,240
    Mentioned
    36 Post(s)
    Quoted
    496 Post(s)

    Default random case question...

    here is the code:
    begin
    Case random (2) of
    0: TypeSend('lets do this');
    1: TypeSend('yay');
    end;
    end;

    now what if i wanted it to do case 0 90% of the time? and case 1 only 10% of the time? how would i do this? i still want it to be random!

  2. #2
    Join Date
    Apr 2007
    Location
    Texas
    Posts
    1,668
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    i know this is kinda cheating... but i forget how to do the shortcut for cases without having to type in 1 , 2, 3, 4, 5, 6, 7, 8; (onl know it for java)
    so the other way would be.
    SCAR Code:
    begin
    if random (10) > 9 then
    begin
     TypeSend('lets do this');
    end
    else begin
      TypeSend('yay');
    end;
    [IMG]http://farm3.static.flickr.com/2120/2052732965_348f3629d0_o.jpg[/IMG]

  3. #3
    Join Date
    Dec 2006
    Location
    Copy pastin to my C#
    Posts
    3,788
    Mentioned
    8 Post(s)
    Quoted
    29 Post(s)

    Default

    @Greg: desperate for syntax errors?

  4. #4
    Join Date
    Apr 2007
    Location
    Texas
    Posts
    1,668
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Quote Originally Posted by n3ss3s View Post
    @Greg: desperate for syntax errors?
    !
    lol, thanks, leavy my lazyness alone, lol
    [IMG]http://farm3.static.flickr.com/2120/2052732965_348f3629d0_o.jpg[/IMG]

  5. #5
    Join Date
    Feb 2007
    Location
    PA, USA
    Posts
    5,240
    Mentioned
    36 Post(s)
    Quoted
    496 Post(s)

    Default

    ok thanks.

    anyone else know a way? other than ifs thens?

    i so wish scar was written in JAVA! id have a much easier time!.....

  6. #6
    Join Date
    Jul 2007
    Location
    St. Louis, Missouri, USA.
    Posts
    575
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    There's the old classic:
    SCAR Code:
    case random (10) of
      0,1,2,3,4,5,6,7,8: TypeSend('lets do this');
      9: TypeSend('yay');
    end;

    But thats annoying. That and gregs way are the only ones I know.
    -You can call me Mick-



  7. #7
    Join Date
    Feb 2007
    Location
    PA, USA
    Posts
    5,240
    Mentioned
    36 Post(s)
    Quoted
    496 Post(s)

    Default

    ty! thats the one i wanted, thanks mick!

  8. #8
    Join Date
    Dec 2006
    Location
    Copy pastin to my C#
    Posts
    3,788
    Mentioned
    8 Post(s)
    Quoted
    29 Post(s)

    Default

    Well footballdjs got what he wanted, but I'll continue the discussion -

    who said you have to use a case?

    SCAR Code:
    program New;
    Var
      I: Integer;
    begin
      I := Random(100);
      If I > 80 Then
        Writeln('I was larger than 80')
      Else
        If I > 50 Then
          Writeln('I was larger than 50, but smaller than 80!')
        Else
          If I > 20 Then
            Writeln('I was larger than 20, but smaller than 50')
          Else
            If I >= 0 Then
              Writeln('I was smaller than 20');
    end.


    Also, who said you couldn't make an array of procedure/function calls?

    Then you will survive with a for loop.

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. case random...
    By NCDS in forum OSR Help
    Replies: 2
    Last Post: 11-26-2008, 06:19 PM
  2. Case help
    By Aser in forum OSR Help
    Replies: 3
    Last Post: 11-22-2008, 05:21 AM
  3. case question
    By Heysus in forum OSR Help
    Replies: 4
    Last Post: 10-03-2008, 01:51 AM
  4. Question on Case/Of
    By Macrosoft in forum OSR Help
    Replies: 11
    Last Post: 07-25-2008, 04:06 AM
  5. Case OF
    By Jagex_Fagex in forum News and General
    Replies: 3
    Last Post: 10-25-2006, 08:45 AM

Posting Permissions

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