Results 1 to 8 of 8

Thread: function causing runtime error

  1. #1
    Join Date
    Oct 2007
    Location
    medway.england
    Posts
    66
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default function causing runtime error

    heers the function

    SCAR Code:
    function  LostCage:boolean;
    begin
    potDTM := DTMFromString('78DA6374676060F06540010DE5E5609A11CA6' +
           '73401129EA86A1C753850D51803096F0634C088AAC60948441250' +
           'E30F24FC5055182828A0AA01C93BE1370700102B05BA');
      if(FindDTM(x, y, potDTM, 549, 199, 609, 259))then
      begin
        Result := False;
        FreeDTM(potDTM);
      end else
      begin
        Result := True;
        FreeDTM(potDTM);
        writeln('pot is lost');
      end;
    end;

    heers the error

    [Runtime Error] : Exception: Access violation at address 006D71E8 in module 'scar.exe'. Read of address 00000000 in line 59 in script C:\Documents and Settings\Zezima\Desktop\Scripts\Catherby.scar

    the function is to check if you lost your lobster pot, it searches the first inv slot for a dtm of the pot(iv tested the dtm and it works) and its not there the result is true. any idea why this is causing this error?

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

    Default

    There dosent seem to be an error with that...Although you could shorten greatly

    SCAR Code:
    function  LostCage:boolean;
    var
    potdtm : integer;
    begin
    potDTM := DTMFromString('78DA6374676060F06540010DE5E5609A11CA6' +
           '73401129EA86A1C753850D51803096F0634C088AAC60948441250' +
           'E30F24FC5055182828A0AA01C93BE1370700102B05BA');

    if not FindDTM(x, y, potDTM, MIX1, MIY1, MIX2, MIY2) then  Result := True;
    end;

  3. #3
    Join Date
    Jun 2007
    Location
    Wednesday
    Posts
    2,446
    Mentioned
    3 Post(s)
    Quoted
    1 Post(s)

    Default

    Are you sure that's line 59? Maybe post the full script as it could be another part of the script with it just being shown as inside the function/the cursor jumping to function.
    By reading this signature you agree that mixster is superior to you in each and every way except the bad ways but including the really bad ways.

  4. #4
    Join Date
    Oct 2007
    Location
    medway.england
    Posts
    66
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    @owner : lol, i totaly forgot you can do "if not"s...thx
    @mixster :hears the full script but im pretty shure the problems in that function as it runs fine with it comented out

  5. #5
    Join Date
    Apr 2007
    Location
    Perth, Australia
    Posts
    3,926
    Mentioned
    3 Post(s)
    Quoted
    2 Post(s)

    Default

    Coco, you've left your password and username in your script. I've changed it for you. Please contact me through MSN or enable your PM's so I can get it back to you.

  6. #6
    Join Date
    May 2007
    Location
    Ohio
    Posts
    2,296
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Quote Originally Posted by cocodog13 View Post
    heers the function

    SCAR Code:
    function  LostCage:boolean;
    begin
    potDTM := DTMFromString('78DA6374676060F06540010DE5E5609A11CA6' +
           '73401129EA86A1C753850D51803096F0634C088AAC60948441250' +
           'E30F24FC5055182828A0AA01C93BE1370700102B05BA');
      if(FindDTM(x, y, potDTM, 549, 199, 609, 259))then
      begin
        Result := False;
        FreeDTM(potDTM);
      end else
      begin
        Result := True;
        FreeDTM(potDTM);
        writeln('pot is lost');
      end;
    end;

    heers the error

    [Runtime Error] : Exception: Access violation at address 006D71E8 in module 'scar.exe'. Read of address 00000000 in line 59 in script C:\Documents and Settings\Zezima\Desktop\Scripts\Catherby.scar

    the function is to check if you lost your lobster pot, it searches the first inv slot for a dtm of the pot(iv tested the dtm and it works) and its not there the result is true. any idea why this is causing this error?
    Simple. You Are Trying To Free A Integer As It Were A DTM..
    SCAR Code:
    FindDTM(x, y, potDTM,
    To
    SCAR Code:
    FindDTM(potDTM, x, y
    Here...
    SCAR Code:
    Function  LostCage: Boolean;
    Begin
      Try
        PotDTM := DTMFromString('78DA6374676060F06540010DE5E5609A11CA6' +
                '73401129EA86A1C753850D51803096F0634C088AAC60948441250' +
                'E30F24FC5055182828A0AA01C93BE1370700102B05BA');
        Result := FindDTM(PotDTM, x, y, MIX1, MIY1, MIX2, MIY2);
        If Not Result Then
          WriteLn('Pot is lost');
      Finally
        FreeDTM(PotDTM);
      Except
        WriteLn('DTM Memory Leak. Saved you from [Runtime Error].');
      End;
    End;

  7. #7
    Join Date
    Nov 2006
    Location
    NSW, Australia
    Posts
    3,487
    Mentioned
    1 Post(s)
    Quoted
    0 Post(s)

    Default

    Quote Originally Posted by Timer View Post
    Simple. You Are Trying To Free A Integer As It Were A DTM..
    SCAR Code:
    FindDTM(x, y, potDTM,
    To
    SCAR Code:
    FindDTM(potDTM, x, y
    Here...
    SCAR Code:
    Function  LostCage: Boolean;
    Begin
      Try
        PotDTM := DTMFromString('78DA6374676060F06540010DE5E5609A11CA6' +
                '73401129EA86A1C753850D51803096F0634C088AAC60948441250' +
                'E30F24FC5055182828A0AA01C93BE1370700102B05BA');
        Result := FindDTM(PotDTM, x, y, MIX1, MIY1, MIX2, MIY2);
        If Not Result Then
          WriteLn('Pot is lost');
      Finally
        FreeDTM(PotDTM);
      Except
        WriteLn('DTM Memory Leak. Saved you from [Runtime Error].');
      End;
    End;
    Your example does the opposite of what he wants. Yours results true if it finds the DTM, but he wants it to result true if it doesn't find it. Also, try/except is quite useless if you can be sure you haven't made any coding mistakes.

    Here:

    SCAR Code:
    Function  LostCage: Boolean;
    Begin
      PotDTM := DTMFromString('78DA6374676060F06540010DE5E5609A11CA6' +
                '73401129EA86A1C753850D51803096F0634C088AAC60948441250' +
                'E30F24FC5055182828A0AA01C93BE1370700102B05BA');

      Result := not(FindDTM(PotDTM, x, y, MIX1, MIY1, MIX2, MIY2));
      if Result then
        WriteLn('Pot Is Lost');
      FreeDTM(PotDTM);
    End;
    [CENTER][img]http://signatures.mylivesignature.com/54486/113/4539C8FAAF3EAB109A3CC1811EF0941B.png[/img][/CENTER]
    [CENTER][BANANA]TSN ~ Vacation! ~ says :I Love Santy[/BANANA][/CENTER]

    [CENTER][BANANA]Raymond - Oh rilie? says :Your smart[/BANANA][/CENTER]

  8. #8
    Join Date
    Oct 2007
    Location
    medway.england
    Posts
    66
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    thx guys, changing it from (x,y,DTM to (DTM,x,y fixed the problem musta missread the manual like 3 times to get that wrong :P exscuse my noobyness

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Replies: 2
    Last Post: 02-26-2008, 08:26 PM
  2. FindFastRandoms Causing runtime error
    By SirPa in forum OSR Help
    Replies: 2
    Last Post: 08-04-2007, 08:58 AM
  3. [Runtime Error] : Exception: buffer error
    By GasMan in forum OSR Help
    Replies: 11
    Last Post: 05-13-2007, 02:07 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
  •