November 26th, 2013, 08:02 PM
Error Access violation in my code..
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...
var i,j: integer;
Nc := 140;
StringGrid1.ColCount := N+2;
StringGrid1.RowCount := Nc+1;
for i:=1 to N do
StringGrid1.Cells[i,0] := 'wajah-'+inttostr(i);
StringGrid1.ColWidths[i] := 200;
for i:=1 to Nc do
StringGrid1.Cells[0,i] := 'Bobot ke-'+inttostr(i);
for j:=1 to N do
StringGrid1.Cells[j,i] := floattostr(PN^[i]^[j]);
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 ....???
November 26th, 2013, 11:05 PM
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...