Page 1 of 1
Forum

Welcome to the Tweaking4All community forums!
When participating, please keep the Forum Rules in mind!

Topics for particular software or systems: Start your topic link with the name of the application or system.
For example “MacOS X – Your question“, or “MS Word – Your Tip or Trick“.

Please note that switching to another language when reading a post will not bring you to the same post, in Dutch, as there is no translation for that post!



Share:
Notifications
Clear all

[Solved] Lazarus - Error 204 or Invalid Pointer when using SetLength with Dynamic Arrays

1 Posts
1 Users
0 Reactions
1,937 Views
 Hans
(@hans)
Famed Member Admin
Joined: 12 years ago
Posts: 2860
Topic starter  

For those familiar with dynamic arrays, functions like Length (determine number of elements in the array) and SetLength (change the dimension of your array) are vital.

Strange enough, on rare occasion, using SetLength() might cause and "Invalid Pointer Operation" (EInvalidPointer) error or a "RunError(204)" ... 

I've had that happen when making a populated array smaller (and not consistently I might add).
The fix was found in "clearing" the array with:

FillChar(MyArray,sizeof(MyArray), #0);

I thought it might be helpful to someone to find this little trick ...


   
ReplyQuote
Share: