OnGetValue compare with FreeReport

edited 7:31PM in FastReport 4.0
Hi Everybody,
I'v just first time run FastReport 4 and I see that OnGetValue works different than in FreeReport.
I want to format DataValue for each record but FR4 doesn't call OnGetValue for data field as .
Do You know how can I write code below in XE+FR4?
I don't whant to use a script inside FR4, I prefer code in my Delhi unit.
// D7+FreeReport
procedure TfrForm.frReport1GetValue(const ParName: String; var ParValue: Variant);
begin
if ParName='Query1."Number"' then
  begin
    if Query1Number.Value>1000 then
       ParValue:=FloatToStrF(Query1Number.Value,fffixed,15,2)
    else
    if Query1Number.Value>100 then
       ParValue:=FloatToStrF(Query1Number.Value,fffixed,15,3)
    else
    if Query1Number.Value>10 then
       ParValue:=FloatToStrF(Query1Number.Value,fffixed,15,4)
    else
       ParValue:='';
  end;
end;

Comments

  • gpigpi
    edited 7:31PM
    Try to use user function
  • edited 7:31PM
    OK, I have a solution... it seems to work good.

    1. On the Delphi form frxDataSet1.DataSet:=Query1
    2. Create variable (eg. Num1 ) on the report and assign it to frxDBDataSet desired field (eg. Number)
    3. Place text label on the report and assign it to variable Num1
    4. In the Delphi code:
    // XE+FR4
    procedure TfrForm.frReport1GetValue(const VarName: String; var VarValue: Variant);
    var
        v:double;
    begin
    if VarName='<frxDBDataset1."Numer">' then
      begin
           v:=frxDBDataset1.Value['Numer'];
            if v>1000 then
               Value:=FloatToStrF(v,ffFixed,15,2)
            else
            if V>100 then
               Value:=FloatToStrF(v,ffFixed,15,3)
            else
            if V>10 then
               Value:=FloatToStrF(v,ffFixed,15,4);
        else
           Value:='';
      end;
    end;
    

    Any other idea?

    Best regards.

Leave a Comment

Rich Text Editor. To edit a paragraph's style, hit tab to get to the paragraph menu. From there you will be able to pick one style. Nothing defaults to paragraph. An inline formatting menu will show up when you select text. Hit tab to get into that menu. Some elements, such as rich link embeds, images, loading indicators, and error messages may get inserted into the editor. You may navigate to these using the arrow keys inside of the editor and delete them with the delete or backspace key.