Source:
// write
Path := 'Data/_prefixed' + dynarray1[v].Name;
with XMLConfig1 do begin;
SetValue(Path + '/RealName', dynarray1[v].Name);
end;
..
// read
Path := 'Data/_prefixed' + listOfVars.Strings[v];
with XMLConfig1 do begin;
dynarray1[v].Name := GetValue(Path + '/RealName', '');
end;
I think about writing simple macro like:
procedure getsetkey(Keyname,Var:string; var Value: **overloaded**; Direction: integer);
getset('Data/_prefixed'+Keyname, Var
but due to different return types it is still three (integer, string, boolean) similar functions (nothing like ?), or ever six function, if I throw out Direction argument and get a sets of setkey and getkey, or key(overload: call set if 4-th parameter presents), (Value is allowed to be empty, so checking the value isn’t the way to decide)
Any way to shorten number of functions and to associate dynarray1[v].Element_Name with a key that may be passed to GetValue()? Some kind of Reflection-like API to access key names?
Variants would be more logical. If you can get reflection/RTTI info (e.g. everything you want to save is a published property) that is also possible.
But IMHO for 3 variants of a 1 line function that is like shooting with a canon on a mosquito