Results 1 to 7 of 7

Thread: [Runtime Error] : Exception: Access violation

  1. #1
    Join Date
    Jul 2008
    Posts
    49
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default [Runtime Error] : Exception: Access violation

    I get this error:
    [Runtime Error] : Exception: Access violation at address 007209A8 in module 'scar.exe'. Read of address 00000000 in line 79 in script C:\Program Files\SCAR 3.20\includes\SRL/SRL/Core/Color.scar

    I think it has to do when im freeing the dtm this the the walk to willow script;
    SCAR Code:
    procedure WalkToWillows;
    var
      x, y, Tries: Integer;
      Result1: Boolean;
    begin
      WillowDTM := DTMFromString('78DA63AC666260F06540010909CA0CFF81342' +
        '310FF0702C63CA01A075435F221109A11CA672C03AAF124A0A619' +
        'A8C68F809A5AA09A285435B24EA86A0082B00B88');
      MakeCompass('N')
      repeat
        if DTMRotated(WillowDTM, x, y, MMx1, MMy1, MMx2, MMy2) then
      begin
          Result1 := True;
          Mouse(x, y, 5, 5, true);
          WriteLn('Walking To Willows');
          FreeDTM(WillowDTM)
      end else
        Result1 := False;
        Tries := Tries + 1;
        Writeln('Could not find WillowDTM');
      FreeDTM(WillowDTM);
      until(Result1 = True) or (Tries = 25)
      end;

    Line 79 of Color.scar:
    SCAR Code:
    if (FindDTM(DTM, x, y, x1, y1, x2, y2)) then

  2. #2
    Join Date
    Jan 2008
    Location
    California, US
    Posts
    2,765
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    You free the DTM twice.

  3. #3
    Join Date
    Oct 2006
    Location
    ithurtsithurtsithurtsithurts
    Posts
    2,930
    Mentioned
    7 Post(s)
    Quoted
    135 Post(s)

    Default

    No matter what happens, you end up freeing the DTM. And if the DTM isn't found the first time, you try and find it again. But as you've already freed the DTM, you get an error when you pass it into DTMRotated.

  4. #4
    Join Date
    Jan 2008
    Location
    Ontario, Canada
    Posts
    7,805
    Mentioned
    5 Post(s)
    Quoted
    3 Post(s)

    Default

    You are trying to access a piece of memory that doesnt exist

    Don't free your DTMs till you are SURE you are done with them
    Writing an SRL Member Application | [Updated] Pascal Scripting Statements
    My GitHub

    Progress Report:
    13:46 <@BenLand100> <SourceCode> @BenLand100: what you have just said shows you 
                        have serious physchological problems
    13:46 <@BenLand100> HE GETS IT!
    13:46 <@BenLand100> HE FINALLY GETS IT!!!!1

  5. #5
    Join Date
    Jan 2008
    Location
    California, US
    Posts
    2,765
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    SCAR Code:
    function WalkToWillows : boolean;
    var
      x, y, Tries: Integer;
    begin
      WillowDTM := DTMFromString('78DA63AC666260F06540010909CA0CFF81342' +
        '310FF0702C63CA01A075435F221109A11CA672C03AAF124A0A619' +
        'A8C68F809A5AA09A285435B24EA86A0082B00B88');
      MakeCompass('N');
      for Tries := 0 to 25 do
      begin
        if DTMRotated(WillowDTM, x, y, MMx1, MMy1, MMx2, MMy2) then
        begin
          Result := True;
          Mouse(x, y, 5, 5, true);
          WriteLn('Walking To Willows');
          FreeDTM(WillowDTM);
          exit;
        end;
      end;
      Writeln('Could not find WillowDTM');
      FreeDTM(WillowDTM);
    end;
    Last edited by Da 0wner; 06-14-2009 at 09:00 AM.

  6. #6
    Join Date
    Oct 2006
    Location
    Ontario,Canada
    Posts
    1,718
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Quote Originally Posted by Da 0wner View Post
    SCAR Code:
    function WalkToWillows : boolean;
    var
      x, y, Tries: Integer;
    begin
      WillowDTM := DTMFromString('78DA63AC666260F06540010909CA0CFF81342' +
        '310FF0702C63CA01A075435F221109A11CA672C03AAF124A0A619' +
        'A8C68F809A5AA09A285435B24EA86A0082B00B88');
      MakeCompass('N');
      for Tries := 0 to 25 do
      begin //<--start of loop
        if DTMRotated(WillowDTM, x, y, MMx1, MMy1, MMx2, MMy2) then
        begin
          Result := True;
          Mouse(x, y, 5, 5, true);
          WriteLn('Walking To Willows');
          FreeDTM(WillowDTM);
          exit;
        end;
        Writeln('Could not find WillowDTM');
        FreeDTM(WillowDTM);
      end; //<---end of loop
    end;
    the FreeDTM has to be out of the loop. that still has it in the while loop. so if it doesnt find it once it will free it and get the access violation.

  7. #7
    Join Date
    Jan 2008
    Location
    California, US
    Posts
    2,765
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Crap, sorry. I know I meant to put that below the end.

Thread Information

Users Browsing this Thread

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

Posting Permissions

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