Hi
Management operators like Initialize & Finalize gets called on entering scope and leaving scope, I think they're just what you're after... See: https://wiki.freepascal.org/management_operators
Regards Benny
I've justed tested it... unfortunately, it does not work for my purposes.
It appears that the Initiialize routine is called
after assignment. Whereas I need it to be called after memory is allocated, but
before assignment. The fact that it is called after assignment, I think is a bug, and sort of defeats the purpose of the idea.
So, to make it clear, my problem happens when a variable is allocated on the stack (e.g. for a function parameter, or a local variable), but has not yet been assigned a value.
If the variable allocation happens
as part of an assignment, and then the initialize routine is called after a value is assigned, then the initialize function overwrites the value created in the assignment.