#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2013
    Posts
    2
    Rep Power
    0

    Error Access violation in my code..


    Hello there...

    I have 600 images with size 46x56 px and I'm using library tpmath to compute principal component of the images....

    And then, I make an update function to renew the column of my TStringGrid...
    This is the code...
    procedure TfrmPCA.updatecolpca;
    var i,j: integer;
    s: string;
    begin
    Nc := 140;
    StringGrid1.ColCount := N+2;
    StringGrid1.RowCount := Nc+1;
    for i:=1 to N do
    begin
    StringGrid1.Cells[i,0] := 'wajah-'+inttostr(i);
    StringGrid1.ColWidths[i] := 200;
    end;
    for i:=1 to Nc do
    begin
    StringGrid1.Cells[0,i] := 'Bobot ke-'+inttostr(i);
    for j:=1 to N do
    begin
    floattostr(PN^[i]^[j]);
    StringGrid1.Cells[j,i] := floattostr(PN^[i]^[j]);
    end;
    end;
    end;
    But if I run my system, I found the message error "Access Violation" in code "floattostr(PN^[i]^[j]);"...

    Is there someone who can help me fix it ....???
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2008
    Posts
    356
    Rep Power
    7
    It would be very difficult for us to figure out why specifically why you are getting the error. You include code, but in that code, it doesn't show how N or PN gets declared nor initialized.

    An access violation is basically telling you that your application is attempting to access memory that the CPU has no address for. If you are getting the error on the line floattostr(PN^[i]^[j]); then my guess is that the array PN at index [I][J] (at what ever the values are for when the error occurs) has not been created, or perhaps, you just don't need to use ^ to point to the array cell. Again, hard to tell since you didn't include that code...

IMN logo majestic logo threadwatch logo seochat tools logo