Results 1 to 10 of 10

Thread: Guide on Cases

  1. #1
    Join Date
    Oct 2007
    Posts
    28
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Guide on Cases

    First off I would like to thank floor66 for teaching me on cases for my old script.

    What is a case?

    A case is like a procedure that does something like picking one of the choices you give it out of a hat. That's the very basics. I will now tell you how to begin your case.

    SCAR Code:
    Program CaseTUT;
    begin
    case random(2) of

    0: begin
            Writeln('good job');
            end;
    1: begin
            Writeln('learning on cases');
            end;
       end;
    end;

    Let's look at each of these things:

    random(2) means that the number in the parenthesis will be the number of options that you put in the case.
    0: is the first option
    1: is the second option

    But this kind of thing can be used for many reasons which all of them I don't know. One I know of though is an auto typer can pick random sentences. There is also a function I believe named FindFastRandoms that uses cases too.

    If you put a loop in here, it will keep repeating the picking of a hat. Like this...

    SCAR Code:
    program loopcasetut;
    begin
    repeat
    case random(3) of
    0: begin
           Writeln('good job');
           end;
    1: begin
           Writeln('learning on cases');
           end;
    2: begin
           Writeln('so far');
           end;
    end;
    until(false);
    end;

    okay... We know that the repeat in bold is repeat and the until(false) at the end will repeat the case forever! The only thing I changed about this is that the number in the random() is instead of 2 it's 3. What this will do instead of the program having two choices to pick from it will have three.


    I hope this helps...

    -Camdo Clark

  2. #2
    Join Date
    Dec 2006
    Posts
    10
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    wow thanks for this =)
    http://www.stats.srl-forums.com/sigs/3052.png

    "Some ppl say money dont grow off trees but in runescape it does."[

  3. #3
    Join Date
    Oct 2007
    Posts
    28
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Quote Originally Posted by kingy101 View Post
    wow thanks for this =)
    Thanks, can you rep me?

  4. #4
    Join Date
    Apr 2007
    Posts
    3,152
    Mentioned
    3 Post(s)
    Quoted
    1 Post(s)

    Default

    ur not supposed to ask for rep, and it should be
    SCAR Code:
    Program CaseTUT;
    begin
    case random(2) of
     
    0: begin
            Writeln('good job');
            end;
    1: begin
            Writeln('learning on cases');
            end;
    end;
    end.

    i think you could go into more detail.
    SCAR Tutorials: The Form Tutorial | Types, Arrays, and Classes
    Programming Projects: NotePad | Tetris | Chess


  5. #5
    Join Date
    Apr 2007
    Location
    The Netherlands
    Posts
    5,553
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    like case whichLeather of

    edit:

    like:

    SCAR Code:
    procedure Choose;
    begin
        case EndSkill of
          1, 2, 3, 4, 5, 6: ItemToCraft := 'gloves';
          7, 8: ItemToCraft := 'boots';
          9, 10: ItemToCraft := 'cowl';
          11, 12, 13: ItemToCraft := 'vambraces';
          14, 15, 16, 17: ItemToCraft := 'body';
          18, 19, 20, 21, 22, 23,
            24, 25, 26, 27, 28, 29, 30, 31, 32,
            33, 34, 35, 36, 37, 38, 39, 40, 41,
            42, 43, 44, 45, 46, 47, 48, 49, 50: ItemToCraft := 'chaps';
        end;
    end;

    procedure PickXandY;
    begin
      case ItemTocraft of
        'gloves':begin
                   XItem := 191;
                   Yitem := 117;
                 end;
        'boots': begin
                   XItem := 316;
                   Yitem := 114;
                 end;
        'cowl': begin
                  XItem := 382;
                  Yitem := 234;
                end;
        'vambraces': begin
                       XItem := 445;
                       Yitem := 247;
                     end;
        'body': begin
                  XItem := 72;
                  Yitem := 109;
                end;
        'chaps': begin
                   XItem := 126;
                   Yitem := 247;
                 end;
      end;
    end;

    ps. endskill is your level(crafting level)
    ~Hermen

  6. #6
    Join Date
    Oct 2007
    Posts
    28
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Thanks, I'll add that. Oh and thanks Dan Cardin for telling me that you shouldn't ask for rep.

  7. #7
    Join Date
    Apr 2007
    Location
    The Netherlands
    Posts
    5,553
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    btw, the rep system is out of air they didnt like it
    ~Hermen

  8. #8
    Join Date
    Oct 2007
    Posts
    28
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Really i thought it was one of the ways to become a junior member like the tut for becoming one said.

    P.S. I added a little more please more feedback.

  9. #9
    Join Date
    Oct 2007
    Posts
    28
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

  10. #10
    Join Date
    Sep 2008
    Posts
    27
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    rep ++ thanks that helped

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Cases - how do I use them?
    By R0b0t1 in forum OSR Help
    Replies: 6
    Last Post: 08-30-2007, 02:37 PM
  2. Cases
    By EL_TYCHO in forum OSR Help
    Replies: 2
    Last Post: 06-26-2007, 11:30 AM
  3. Cases
    By inSaner in forum OSR Help
    Replies: 7
    Last Post: 05-06-2007, 04:50 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
  •