Results 1 to 8 of 8

Thread: Error Message

  1. #1
    Join Date
    Jun 2007
    Posts
    47

    Error Message

    Why do i get this error message (will post code if needed) couldn't find much about it.

    Exception EInvalidPointer in Module ProjectName at SomeAddress
    Invalid pointer operation

  2. #2
    Join Date
    Jan 2007
    Posts
    216
    please do post some code, it's almost always impossible to tell where the error is, without looking at the code

  3. #3
    Join Date
    Jun 2007
    Posts
    47
    Code:
    var
      FRMIntegration: TFRMIntegration;
      N:integer;
      A, B, X, W,Midheights,trapheights,Odd,Even,Area:real;
      heights:Array of real;
    
    implementation
    
    {$R *.dfm}
    
    procedure TFRMIntegration.BTNOutputClick(Sender: TObject);
    Var i, NumOfStrips:integer;
    begin
    
    N:=1;
    NumOfStrips := 1;
    A:= strtofloat(EDTA.Text);
    B:= strtofloat(EDTB.Text);
    
    LBMid.Clear;
    LBTrap.Clear;
    LBSimp.Clear;
    LBStrips.Clear;
    
    for i := 1 to (cbpowers.ItemIndex + 1) do
    begin
    NumOfStrips := NumOfStrips * 2;
    LBstrips.Items.Add(inttostr(NumOfStrips));
    end;
    
    LBStrips.Items.Insert(0,'1');
    
    setlength(heights, numofstrips);
    
     repeat
       begin
        midheights := 0;
        trapheights := 0;
        odd := 0;
        even := 0;
        W := (B - A)/ N;
    
        Trapezium(N);
        LBtrap.Items.Add(floattostr(Area));
    
        Midpoint(N);
        LBmid.Items.Add(floattostr(Area));
    
        Simpsons(N);
        LBsimp.Items.Add(floattostr(Area));
    
        n := n *2;
       end
     until n > NumOfStrips;
    heights := nil;

  4. #4
    Join Date
    Jan 2007
    Posts
    216
    are you trying to aproximate Integrals???

    ANYWAY, they only thing I can imagine where a pointer error can occure would be the last line
    Code:
    heights := nil
    Can't you just set the length to 0?

  5. #5
    Join Date
    Nov 2006
    Location
    UK
    Posts
    3,774
    That would be my thoughts to DC.
    Delphi !ROCKS!
    Got a question? Read this first!!!
    "You gotta help us, Doc. We've tried nothin' and we're all out of ideas"

  6. #6
    Join Date
    Jun 2007
    Posts
    47
    Yes im aproximating Integrals.. i had the message before i added heights := nil;
    i only added this because i read up on dynamic array and it said you should have that line to free the memory and i thought it mite solve the problem but i didnt.

  7. #7
    Join Date
    Nov 2006
    Location
    UK
    Posts
    3,774
    Setting it to nil just makes a leak, it doesnt free it (this isnt c#)
    In which case.. I bet if you step through your code the mistake is more obvious.

    the only thing Id say to you is if you have 1 things, you assume 1 to 10 (as a human) pascal sees 0 to 9 ... be sure that you have allowed for that.
    Delphi !ROCKS!
    Got a question? Read this first!!!
    "You gotta help us, Doc. We've tried nothin' and we're all out of ideas"

  8. #8
    Join Date
    Jun 2007
    Posts
    47
    It was something to do with the array boundry like you said liz.

Posting Permissions

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