Results 1 to 11 of 11

Thread: Case/Of Tutorial For Beginners

  1. #1
    Join Date
    Jun 2006
    Location
    Canada
    Posts
    1,610
    Mentioned
    1 Post(s)
    Quoted
    0 Post(s)

    Case/Of Tutorial For Beginners

    This is just a short Tut on how to use the Case/Of commands. First of all here is an example of what a Case/Of command is.....

    SCAR Code:
    procedure ProcedureNameHere;
    begin
      begin
        DefineAge := Random (6)
        Case DefineAge of
        0 : thing2
        1 : thing2
        2 : thing3
        3 : thing4
        4 : thing5
        5 : thing6
      end;
    end;


    The Case/Of command is useful when you want SCAR to do one(or two or whatever number) of things from a list you have provided. For this Tut we will only be covering doing one random thing. We will be making a anti - ban procedrue.

    Step 1 : Open the Anti Ban file in the SRL include (there are many examples of Case/Of commands in this include)

    Step 2: Make a list of anti ban procedures you want for your anti ban procedure (ex. LeaveScreenEvery, or HoverSkill)

    Step 3: Oncle you have chosen your procedures/functions you can start making your own anti ban function (you should have 10+ well banlenced functions in your script)

    Step 4: Open SCAR to begin wrinting your function (include SRL)

    Step 5: Writing the proedure

    NOTE: In scar the numbers start at 0 so if you have 6 procedures it'll go 0,1,2,3,4,5

    SCAR Code:
    procedure //ProcedureNameHere;
    var
      random : integer;//define variables here (thanks for the heads up LaBo! =P)
    begin  
      case random() of //put number of procedures fom the include you'll be using in between()
      0: //Antiban thing one
      1://Antiban thing two
      2://Antiban thing three ect.
    end;

    AND YOUR DONE!!! CONGRATZ! YOU CAN USE Case/Of COMMANDS!!!

    heres a example by LaBo!

    SCAR Code:
    procedure ProcedureNameHere;
    var
      DefineAge: integer;
    begin
      ClearDebug;
      DefineAge := Random (6)
      Case DefineAge of
      0 : writeln('Case number 0(zero).');
      1 : writeln('Case number 1(one).');
      2 : writeln('Case number 2(two).');
      3 : writeln('Case number 3(three).');
      4 : writeln('Case number 4(four).');
      5 : writeln('Case number 5(five).');
      end;
    end;


    Need any more help just read my Siggy h):

    If i need to add more just post it or PM me and i'll add to it....I kinda rushed this

    Accept that the waters around you have grown.

  2. #2
    Join Date
    Feb 2006
    Location
    Helsinki, Finland
    Posts
    1,395
    Mentioned
    30 Post(s)
    Quoted
    107 Post(s)

    Default

    You didn't end cases in your examples. =) So newbies might get confused. But, I am sure you made this for people who already know more than just basics, right?

    Anyways, good job with the tutorial, man. It's really good you made this tutorial! I am sure it will help out some people. Just fix the bugs and it will be great.

    Edit: You didn't declare the variable.. In your first example.

    Maybe you should put there some examples that really do something whenever they are used?

    This could be the first Example:
    SCAR Code:
    procedure ProcedureNameHere;
    var
      DefineAge: integer;
    begin
      ClearDebug;
      DefineAge := Random (6)
      Case DefineAge of
      0 : writeln('Case number 0(zero).');
      1 : writeln('Case number 1(one).');
      2 : writeln('Case number 2(two).');
      3 : writeln('Case number 3(three).');
      4 : writeln('Case number 4(four).');
      5 : writeln('Case number 5(five).');
      end;
    end;

    -Janilabo

  3. #3
    Join Date
    Jun 2006
    Location
    Canada
    Posts
    1,610
    Mentioned
    1 Post(s)
    Quoted
    0 Post(s)

    Default

    Quote Originally Posted by LaBo View Post
    You didn't end cases in your examples. =) So newbies might get confused. But, I am sure you made this for people who already know more than just basics, right?
    yep I did. I would have mde it more simple if i thought SCAR noobs had a use for this kinda thing but i mught in the future.

    Anyways, good job with the tutorial, man. It's really good you made this tutorial! I am sure it will help out some people. Just fix the bugs and it will be great.

    Quote Originally Posted by LaBo View Post
    You didn't declare the variable.. In your first example.
    ouch, and thats why you dont write tuts when you are tired! Thanks for the example. I will use!

    Accept that the waters around you have grown.

  4. #4
    Join Date
    Feb 2006
    Location
    Tracy/Davis, California
    Posts
    12,631
    Mentioned
    135 Post(s)
    Quoted
    418 Post(s)

    Default

    Its also good for random talking stuff like this:

    Case Random(6)+1 of // the +1 makes the random start at 1 instead of 0.
    1: TypeSend('asdf')
    2 : TypeSend('asdf')
    3 : TypeSend('asdf')
    4 : TypeSend('asdf')
    5 : TypeSend('asdf')
    6 : TypeSend('asdf')
    end;

    idk just another way to use it =)

  5. #5
    Join Date
    Jun 2006
    Location
    Canada
    Posts
    1,610
    Mentioned
    1 Post(s)
    Quoted
    0 Post(s)

    Default

    yah that to yoho

    Accept that the waters around you have grown.

  6. #6
    Join Date
    Feb 2006
    Posts
    406
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    you forgot else

    you can put else at the end to trigger if it didnt fall into any other catergories

    ex
    SCAR Code:
    program aweso;
    var
      rand: integer;
    begin
      rand := Random (2)
      Case rand of
        0 : writeln('zero');
        else writeln('not a 0, must be a 1')
      end;
    end.

  7. #7
    Join Date
    Jun 2006
    Location
    Canada
    Posts
    1,610
    Mentioned
    1 Post(s)
    Quoted
    0 Post(s)

    Default

    >.< D'OH!!!

    Accept that the waters around you have grown.

  8. #8
    Join Date
    Jun 2006
    Location
    The Netherlands
    Posts
    2,984
    Mentioned
    3 Post(s)
    Quoted
    1 Post(s)

    Default

    Quote Originally Posted by yohojo8 View Post
    Its also good for random talking stuff like this:

    Case Random(6)+1 of // the +1 makes the random start at 1 instead of 0.
    1: TypeSend('asdf')
    2 : TypeSend('asdf')
    3 : TypeSend('asdf')
    4 : TypeSend('asdf')
    5 : TypeSend('asdf')
    6 : TypeSend('asdf')
    end;

    idk just another way to use it =)
    Then it could end at 7

  9. #9
    Join Date
    Dec 2007
    Location
    UK
    Posts
    479
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Thanx. Helpfull Tutorial! =)
    I don't play runescape. I auto it

  10. #10
    Join Date
    Feb 2008
    Posts
    34
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Helpful Programming Connection

    In other programming languages, these 'case' statements are called 'switch statements'. Switch statements are common to most major programming languages including but not limited to:
    C
    C++
    C#
    Java


    P.S. This is a great tutorial(set). Everybody should know how to do this.

  11. #11
    Join Date
    Aug 2008
    Posts
    0
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    thank you it helped me a lot

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. The Beginners HandBook
    By Waddo in forum OSR Outdated Tutorials
    Replies: 4
    Last Post: 06-11-2009, 09:26 PM
  2. Basic programming tutorial, A must read for beginners!
    By boberman in forum Outdated Tutorials
    Replies: 5
    Last Post: 09-07-2008, 07:38 AM
  3. nned a case tutorial please
    By RudeBoiAlex in forum OSR Help
    Replies: 10
    Last Post: 08-18-2007, 11:00 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
  •