Using the April 25th version on Lazarus 1.6 32b FPC 3 on Windows 7 64b, continuing the added field, please note that adding a value on the field does not look like it is updated as per the below code.
Please advise.
Code: Select all
procedure TVirtualPop.DoRun;
var
Source: TVirtualTable;
begin
Source := TVirtualTable.Create(nil);
Source.FieldDefs.Add('ID', ftInteger);
Source.FieldDefs.Add('AGE', ftInteger);
Source.Open;
Source.AppendRecord([1]);
Source.Close;
Source.FieldDefs.Add('A', ftString);
Source.Open;
writeln('NmbFields:' + IntToStr(Source.FieldCount));
try
with Source do
begin
if Locate('ID', 1, []) then
begin
Edit;
FieldByName('ID').AsInteger := 101;
FieldByName('AGE').AsInteger := 25;
FieldByName('A').AsString := 'TEST';
Post;
writeln(FieldByName('ID').AsString); //returns 101
writeln(FieldByName('AGE').AsString); //returns 25
writeln(FieldByName('A').AsString); //returns empty
end;
end;
except
on E: Exception do
begin
writeln('Error:' + E.Message); //prints list index out of bounds
end;
end;