I have read most of the posts here on invalid pointer operations in Delphi and they don't seem to apply to this case... Trial and error led me to the line with the problem but it doesn't make any sense to me. In this example, a dynamic array of records is populated with the contents of a text file as it parses it. Everything works perfectly except when the memory allocated to the dynamic array is released - in that case I receive an "Invalid Pointer Operation". When I change the line in question from an ifthen statement to a classic if-then, it works.
My question is simple: Why does the first one cause it to fail to release the memory but the but the second one succeeds?
First Example:
TempFTDB[ci].FTText := ifthen(TempHolder = '', '', TempHolder + #13#10) + lr;
Second Example:
if tempholder = '' then
TempFTDB[ci].FTText := lr
else
TempFTDB[ci].FTText := tempholder + #13#10 + lr;
The line that releases the memory is:
TempFTDB := nil;
Further clarification: TempFTDB is a local variable and there are no other lines that free it's memory. It is on the "TempFTDB := nil" line that the error occurs.