#12 setting a record member clears other members

open
5
2005-05-05
2005-05-05
Thomas Mueller
No

When you set a record's member value from the Delphi program
like this:

info.vars['myrecordvariable'].member['a'] := 5;

it clears the values of all other members of this variable, so this:

info.vars['myrecordvariable'].member['a'] := 5;
info.vars['myrecordvariable'].member['b'] := 2;

will result in myrecordvariable.a being empty and myrecordvariable.
b containing 2.

Workaround:

Use a with statement so the program won't fetch the vars pointer
multiple times:

with info.vars['myrecordvariable'] do begin
member['a'] := 5;
member['b'] := 2;
end;

(Setting variable values from Delphi of course only works after the
script has been compiled and BeginProgram has been called.)

Discussion