Recent

Author Topic: LazReport: Error using HideZeroValues with formula including more variables  (Read 136 times)

luca

  • Jr. Member
  • **
  • Posts: 71
Hi,
I found this problem setting HideZeroValues to true.

The procedure:
Code: Pascal  [Select][+][-]
  1. procedure TfrReport.GetVariableValue(const s: String; var aValue: Variant);
in LR_Class checks the status of the flag for every variable in the formula using the code below:
Code: Pascal  [Select][+][-]
  1.   //check if CurView is TfrBandView to avoid clash with flBandPrintChildIfNotVisible. Issue 29313
  2.   if Assigned(CurView) and ((CurView.Flags and flHideZeros <> 0) and not (CurView is TfrBandView)) then
  3.   begin
  4.     if TVarData(aValue).VType in [varSmallInt, varInteger, varCurrency,
  5.        varDecimal, varShortInt, varByte, varWord, varLongWord, varInt64,
  6.        varQWord, varDouble, varSingle] then
  7.     begin
  8.       if aValue = 0 then
  9.         aValue:=Null;
  10.     end;
  11.   end;  
  12.  

If one variable has zero value the procedure return Null.
This provokes an error in the formula calculation resulting in a report not completely created.
I found a workround by commenting the code above and inserting the code below in the procedure (dummy is an integer variable)
Code: Pascal  [Select][+][-]
  1. procedure TfrCustomMemoView.ExpandVariables;
  2. var
  3. ...
  4.  dummy:integer;
  5. ...
  6.  
  7.   for i := 0 to Memo.Count - 1 do
  8.   begin
  9.     s := Memo[i];
  10.     if Length(s) > 0 then
  11.     begin
  12.       GetData(s);
  13. //NEW CODE
  14.       if Assigned(CurView) and ((CurView.Flags and flHideZeros <> 0) and not (CurView is TfrBandView)) then
  15.        if TryStrToInt(s,dummy) then if dummy=0 then s:='';
  16. //END OF NEW CODE
  17.       Memo1.Add(s)
  18.     end
  19.     else
  20.       Memo1.Add('');
  21.   end;
  22.  
  23. ---
  24.  

This work in my case BUT I'm not sure this is the correct way to fix the problem.

Regards

« Last Edit: May 18, 2022, 05:48:11 pm by luca »

 

TinyPortal © 2005-2018