I have the following code
....
lReportData := TFPReportUserData.Create(Self);
lReportData.Name:='userdata';
lReportData.OnGetValue := @GetReportDataValue;
lReportData.OnGetEOF := @GetReportDataEOF;
lReportData.OnFirst := @GetReportDataFirst;
lReportData.OnGetNames := @GetReportDataNames;
lReportData.InitFieldDefs;
InitialiseData;
....
p := TFPReportPage.Create(FReport);
p.Orientation := poPortrait;
p.PageSize.PaperName := 'A4';
p.Data := lReportData;
....
Memo := TFPReportMemo.Create(DataBand);
Memo.Font.Name := defaultFont;
Memo.Text := 'Hello world <[userdata.string]>.';
....
procedure TFrmSimpleReportLCL.GetReportDataFirst(Sender: TObject);
begin
// Nothing to do yet, but needed
end;
procedure TFrmSimpleReportLCL.GetReportDataValue(Sender: TObject;
const AValueName: String; var AValue: Variant);
begin
if (AValueName = 'element') or (AValueName = 'string') then
begin
AValue := sl[lReportData.RecNo-1];
end
else
AValue:=AValueName+IntToStr(lReportData.RecNo);
end;
procedure TFrmSimpleReportLCL.GetReportDataEOF(Sender: TObject;
var IsEOF: Boolean);
begin
if lReportData.RecNo > sl.Count then
IsEOF := True
else
IsEOF := False;
end;
procedure TFrmSimpleReportLCL.GetReportDataNames(Sender: TObject;
List: TStrings);
begin
List.Add('element');
List.Add('string');
List.Add('FirstName');
List.Add('LastName');
List.Add('DateOfBirth');
List.Add('Gender');
List.Add('Email');
end;
procedure TFrmSimpleReportLCL.InitialiseData;
var
i: integer;
begin
sl := TStringList.Create;
for i := 1 to 50 do
sl.Add(Format('Item %d', [i]));
end;
....
This code was working some time ago, but something is changed in the expressionparser, now i got the errormessage .... EExprParser ... 'Unknown identifier: userdata.string
The full code is in lazarus trunk examples\fpreport\simple\SimpleReportLCL.lpr.
I have looked in the wiki of fpreport, but the TFPReportUserData have not explained. Any hint what is changed/going wrong now?
Andreas