Results 1 to 14 of 14

Thread: Arrays and Case of!??

  1. #1
    Join Date
    Mar 2007
    Posts
    276
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default Arrays and Case of!??

    Ok, Ive been looking at Arrays, but i dont see the difference between Arrays and Case of... There is prolly a big difference but, im still learning them and there hard >< well atleast for me..



    Ive been wanting to upgrade my scripts instead of just using FindColor and Find Color tolernace.. So i think arrays help alot in that subject


    Someone: 'Who the hell is TooManySitUps?'

    Boreas: 'Switch the first and last letter of my name, what do you get?'

    Someone: 'Um, SoreAb?'

    Boreas: 'And how do you get that?'

    Someone: 'From Too Many Sit Ups!! Haha, Boreas you are so clever!'

    Boreas: 'Ya he's like my evil twin that takes over when I'm being really sarcastic, or playing devil's advocate.'

  2. #2
    Join Date
    Sep 2006
    Location
    New Jersey, USA
    Posts
    5,347
    Mentioned
    1 Post(s)
    Quoted
    3 Post(s)

    Default

    SCAR Code:
    Case x of //x is a variable
      0: writeln('x is 0');
      1: writeln('x is 1');
      2: writeln('x is 2');
      3: writeln('x is 3');
      6: writlen('x is 6');
      11: writeln('x is too big for me to count');
    end;

    SCAR Code:
    Program ArrayExample;
    var
      arr: Array of Integer; //You can also set the array's length here; IE: arr: Array[0..9] of Integer;
      avg, i: integer;

    begin
      SetArrayLength(arr, 10); //Sets the array length to 10, meaning that it can hold up to 10 values
      arr[0] := 50;
      arr[1] := 10;
      arr[2] := 27;
      arr[3] := 36;
      arr[4] := 89;
      arr[5] := 41;
      arr[6] := 26;
      arr[7] := 74;
      arr[8] := 91;
      arr[9] := 18;

      for i := 0 to GetArrayLength(arr) - 1 do //Loops through all the array values
      begin
        avg := avg + arr[i]; //badly labeled variable warning =P  This stores the sum of all values in this array
        writeln('Arr[' + inttostr(i) + '] is equal to ' + inttostr(arr[i])); //writes out the current array value
      end;
      writeln('The average of all the values in array arr is ' + inttostr(avg / GetArrayLength(arr))); //writes out the average of all values in the array
    end.

    That should help some

    There's some great tut's on these, which I strongly recommend you read
    Interested in C# and Electrical Engineering? This might interest you.

  3. #3
    Join Date
    Jan 2007
    Location
    Kansas
    Posts
    3,760
    Mentioned
    1 Post(s)
    Quoted
    3 Post(s)

    Default

    very nice example Smartz, explained it pretty well for people who don't know.


  4. #4
    Join Date
    Dec 2006
    Location
    Third rock from the sun.
    Posts
    2,510
    Mentioned
    4 Post(s)
    Quoted
    1 Post(s)

    Default

    Ive been wanting to upgrade my scripts instead of just using FindColor and Find Color tolernace.. So i think arrays help alot in that subject
    Arrays are great for finding colors. They are

    Here's a small example:

    SCAR Code:
    program New;

    var
    TinColor: Array [1..9] of Integer;
    i: Integer;

     procedure DeclareColors;
      begin
       TinColor[1] := 6645101;
       TinColor[2] := 5789790;
       TinColor[3] := 5987170;
       TinColor[4] := 7434874;
       TinColor[5] := 8553356;
       TinColor[6] := 8092549;
       TinColor[7] := 6053220;
       TinColor[8] := 4803152;
       TinColor[9] := 6381929;
      end;

     procedure ClickTin;
      begin
       for i := 1 to 9 do
        begin
         if FindColorSpiralTolerance(x, y, TinColor[i], MSX1, MSY1, MSX2, MSY2, 5) then
          begin
           DoStuff;
           DoOtherStuff;
           DoSomeMoreStuff;
          end;
        end;
      end;

    begin
     DeclareColors;
     ClickTin;
    end.

  5. #5
    Join Date
    Jan 2007
    Location
    Kansas
    Posts
    3,760
    Mentioned
    1 Post(s)
    Quoted
    3 Post(s)

    Default

    Yes they are, I'm using arrays for my autofighter to store colors.


  6. #6
    Join Date
    Mar 2007
    Posts
    276
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Quote Originally Posted by Jason2gs View Post
    Arrays are great for finding colors. They are

    Here's a small example:

    SCAR Code:
    program New;

    var
    TinColor: Array [1..9] of Integer;
    i: Integer;

     procedure DeclareColors;
      begin
       TinColor[1] := 6645101;
       TinColor[2] := 5789790;
       TinColor[3] := 5987170;
       TinColor[4] := 7434874;
       TinColor[5] := 8553356;
       TinColor[6] := 8092549;
       TinColor[7] := 6053220;
       TinColor[8] := 4803152;
       TinColor[9] := 6381929;
      end;

     procedure ClickTin;
      begin
       for i := 1 to 9 do
        begin
         if FindColorSpiralTolerance(x, y, TinColor[i], MSX1, MSY1, MSX2, MSY2, 5) then
          begin
           DoStuff;
           DoOtherStuff;
           DoSomeMoreStuff;
          end;
        end;
      end;

    begin
     DeclareColors;
     ClickTin;
    end.

    How would i do something like, if it found one of the colors, than stop, so it dosent keep clicking all the colors?


    Someone: 'Who the hell is TooManySitUps?'

    Boreas: 'Switch the first and last letter of my name, what do you get?'

    Someone: 'Um, SoreAb?'

    Boreas: 'And how do you get that?'

    Someone: 'From Too Many Sit Ups!! Haha, Boreas you are so clever!'

    Boreas: 'Ya he's like my evil twin that takes over when I'm being really sarcastic, or playing devil's advocate.'

  7. #7
    Join Date
    Dec 2006
    Location
    Third rock from the sun.
    Posts
    2,510
    Mentioned
    4 Post(s)
    Quoted
    1 Post(s)

    Default

    Break; to "break" away from the loop. (For..To..Do)

    Exit; to get away from the procedure altogether.

    Your choice.

  8. #8
    Join Date
    Mar 2007
    Posts
    276
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Wait where do i put the break?


    Someone: 'Who the hell is TooManySitUps?'

    Boreas: 'Switch the first and last letter of my name, what do you get?'

    Someone: 'Um, SoreAb?'

    Boreas: 'And how do you get that?'

    Someone: 'From Too Many Sit Ups!! Haha, Boreas you are so clever!'

    Boreas: 'Ya he's like my evil twin that takes over when I'm being really sarcastic, or playing devil's advocate.'

  9. #9
    Join Date
    Dec 2006
    Location
    Third rock from the sun.
    Posts
    2,510
    Mentioned
    4 Post(s)
    Quoted
    1 Post(s)

    Default

    SCAR Code:
    if FindColorSpiralTolerance(x, y, TinColor[i], MSX1, MSY1, MSX2, MSY2, 5) then
     begin
      DoStuff;
      DoOtherStuff;
      DoSomeMoreStuff;
      Break;
     end;

  10. #10
    Join Date
    Mar 2007
    Posts
    276
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Thats what i did, And it Says Identifer Expected in Script...


    Someone: 'Who the hell is TooManySitUps?'

    Boreas: 'Switch the first and last letter of my name, what do you get?'

    Someone: 'Um, SoreAb?'

    Boreas: 'And how do you get that?'

    Someone: 'From Too Many Sit Ups!! Haha, Boreas you are so clever!'

    Boreas: 'Ya he's like my evil twin that takes over when I'm being really sarcastic, or playing devil's advocate.'

  11. #11
    Join Date
    Dec 2006
    Location
    Third rock from the sun.
    Posts
    2,510
    Mentioned
    4 Post(s)
    Quoted
    1 Post(s)

    Default

    Post script, please?

  12. #12
    Join Date
    Mar 2007
    Posts
    276
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Here it is


    Someone: 'Who the hell is TooManySitUps?'

    Boreas: 'Switch the first and last letter of my name, what do you get?'

    Someone: 'Um, SoreAb?'

    Boreas: 'And how do you get that?'

    Someone: 'From Too Many Sit Ups!! Haha, Boreas you are so clever!'

    Boreas: 'Ya he's like my evil twin that takes over when I'm being really sarcastic, or playing devil's advocate.'

  13. #13
    Join Date
    Dec 2006
    Location
    Third rock from the sun.
    Posts
    2,510
    Mentioned
    4 Post(s)
    Quoted
    1 Post(s)

    Default

    Change line 123 to:

    SCAR Code:
    for i := 1 to 9 do

    And you have it Break;ing before it does what you want it to. I'm not sure if that'll cause problems or not, just know that if something doesn't work right, you could try moving the Break; down to one of the last things in the If..Then

  14. #14
    Join Date
    Mar 2007
    Posts
    276
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    EDIT: Is there another way to stop finding the colors after one has been found, Onstead of stoping the procedure???????????


    Someone: 'Who the hell is TooManySitUps?'

    Boreas: 'Switch the first and last letter of my name, what do you get?'

    Someone: 'Um, SoreAb?'

    Boreas: 'And how do you get that?'

    Someone: 'From Too Many Sit Ups!! Haha, Boreas you are so clever!'

    Boreas: 'Ya he's like my evil twin that takes over when I'm being really sarcastic, or playing devil's advocate.'

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Case help
    By Aser in forum OSR Help
    Replies: 3
    Last Post: 11-22-2008, 05:21 AM
  2. Arrays, stuck on arrays
    By Camaro' in forum OSR Help
    Replies: 1
    Last Post: 03-08-2008, 02:02 AM
  3. Case - Else
    By stylen in forum OSR Help
    Replies: 0
    Last Post: 05-30-2007, 11:54 PM
  4. 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
  •