I don’t know about the “Unknown identifier” error, though on the face of it this looks like the TRecTest type hasn’t been properly described to the PascalScript engine such that it simply doesn’t know about the “Value” field in that context.
But with respect to the changed value not appearing to take effect, I think this could be the result of the fact that tecords are value types, not reference types. So in your script when you write:
obj.RecNested
You are effectively creating a copy of the current fRecNested member record. When you then modify a field in that record you are modifying a copy of fRecNested, not fRecNested itself.
i.e. this code:
obj.RecNested.Value := 5;
is equivalent to:
v := obj.RecNested;
v.Value := 5;
To modify the fRecNested member record using a write property of that record type, you must provide a new, complete record value:
var
v: TRecNested;
...
v.Value := 5;
obj.RecNested := v;
The easiest way to avoid this confusion (and the potential for such mistakes), is to make the record member property read only and provide an explicit SetXXX() method, so that it is clear that a new record value must be provided. Or, if only certain fields in the record need to be modifiable, provide specific SetXXX() methods for those fields: