Results 1 to 4 of 4

Thread: HELP With My Procedure!!!

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

    Default HELP With My Procedure!!!

    Hey, i had made a procedure FindTree but it doesnt seem to work, i get an error while compiling.

    Here is the script.
    SCAR Code:
    Program Testing;
    {.Include SRL/SRL.Scar}

    Procedure FindTree(SomeLetters : String; TreeColor, TreeTol, StumpColor, StumpTol : Integer);
    {FindTree('illo', 21313973, 10, 5847397, 5);}
    Var
      TX, TY : Integer;
      SX, SY : Integer;
      Found  : Boolean;
    Begin
     If(FindObj(TX, TY, SomeLetters, TreeColor, TreeTol))And(Not(FindObj(SX, SY, 'tump', StumpColor, StumpTol)))Then
      MMouse(TX, TY, 15, 15);
       If(IsUpText(SomeLetters))Then
      WriteLn('Tree Found.');
     Found := True;
    End Else
     If(Not(FindObj(TX, TY, SomeLetters, TreeColor, TreeTol)))And(FindObj(SX, SY, 'tump', StumpColor, StumpTol))Then
      MMouse(SX, SY, 5, 5);
       If(Not(IsUpText(SomeLetters))Then
      WriteLn('Tree Not Found.');
     Found := False;
    End;

    Begin
    SetUpSRL;
    Begin
    FindTree('illo', 21313973, 10, 5847397, 5);
    End;
    End.

    Here Is The Procedure.
    SCAR Code:
    Procedure FindTree(SomeLetters : String; TreeColor, TreeTol, StumpColor, StumpTol : Integer);
    {FindTree('illo', 21313973, 10, 5847397, 5);}
    Var
      TX, TY : Integer;
      SX, SY : Integer;
      Found  : Boolean;
    Begin
     If(FindObj(TX, TY, SomeLetters, TreeColor, TreeTol))And(Not(FindObj(SX, SY, 'tump', StumpColor, StumpTol)))Then
      MMouse(TX, TY, 15, 15);
       If(IsUpText(SomeLetters))Then
      WriteLn('Tree Found.');
     Found := True;
    End Else
     If(Not(FindObj(TX, TY, SomeLetters, TreeColor, TreeTol)))And(FindObj(SX, SY, 'tump', StumpColor, StumpTol))Then
      MMouse(SX, SY, 5, 5);
       If(Not(IsUpText(SomeLetters))Then
      WriteLn('Tree Not Found.');
     Found := False;
    End;

    And Here Is The Stupid Error.
    SCAR Code:
    Failed when compiling
    Line 16: [Error] (16006:5): Semicolon (';') expected in script

    Please help me because i really need this procedure.
    Woot woot.

  2. #2
    Join Date
    Aug 2007
    Posts
    429
    Mentioned
    0 Post(s)
    Quoted
    2 Post(s)

    Default

    Here. Posted comments

    SCAR Code:
    Procedure FindTree(SomeLetters : String; TreeColor, TreeTol, StumpColor, StumpTol : Integer);
    {FindTree('illo', 21313973, 10, 5847397, 5);}
    Var
      TX, TY : Integer;
      SX, SY : Integer;
      Found  : Boolean;
    Begin
     If(FindObj(TX, TY, SomeLetters, TreeColor, TreeTol))And(Not(FindObj(SX, SY, 'tump', StumpColor, StumpTol)))Then
     begin //begin here since u are doing MORE THAN ONE THING after the 'if then'
       MMouse(TX, TY, 15, 15);
       If(IsUpText(SomeLetters))Then
       WriteLn('Tree Found.');
       Found := True;
     End Else //this ends the begin
     begin //begin here
       //the lines that were here are not necessary =] as if it DOESN'T 'FindObj' is the reason it'd
        //be here in the first place =] no reason to repeat it. if that makes sense?
       WriteLn('Tree Not Found.');
       Found := False;
     end; //end here
    End;

  3. #3
    Join Date
    Dec 2007
    Posts
    103
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    EDIT: Yeah, okay, Derek beat me.

    Well, one of the errors is that when you use more than one line in an IF-statement you have to add begin (and else at the end).
    Like this:
    Code:
    If (something(something)) Then
    begin
    Line1;
    Line2;
    end;
    Otherwise it will only run the first line after "then" (Line1 here). In your case it will for example only run the WriteLn and not set Found to true. If that's what you intend to do, that is!
    This sentence is false.

  4. #4
    Join Date
    Oct 2007
    Posts
    742
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Hey guys thanks alot. You help was ownage.
    Woot woot.

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Procedure?
    By shadowrec0n in forum OSR Help
    Replies: 3
    Last Post: 02-11-2008, 09:04 PM
  2. Procedure TypeSendRandom & Procedure AutoResponder!
    By Ultra in forum Research & Development Lounge
    Replies: 12
    Last Post: 01-08-2008, 07:04 PM
  3. Help with Procedure
    By Esteban in forum OSR Help
    Replies: 8
    Last Post: 07-06-2007, 03:45 AM
  4. Replies: 8
    Last Post: 05-24-2007, 11:57 PM
  5. Procedure that calls random procedure?
    By Secet in forum OSR Help
    Replies: 2
    Last Post: 03-03-2007, 03:56 PM

Posting Permissions

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