Home General
New Blog Posts: Merging Reports - Part 1 and Part 2

RAP Pass-thru Divide by Zero, not working?

edited July 2001 in General
Hello Newsgroup,

I have a request. I have tried to get two functions to work in the RAP
pass-thru. I can't get the functions I've built to work with a divide by
zero. The following is the code I've used to do this. The code compiles and
installs properly as a package. I'm then able to see the two functions in
the Language area of the ReportBuilder. However, when I run the report, it
seems to work in the Preview mode, showing the results, but when I run in
Real time, the functions do not work properly. Could someone take this code
and install it on your test machine, to see what kind of result you get.
Dividing by Zero doesn't seem to work?

Thank you,
Randy

*****************************************************

unit AulRapFunctions;

interface

uses Forms, raFunc, ppRTTI, sysutils;

type

TMyAulFunctions = class (TraSystemFunction)
public
class function Category: String; override;
end;

TIntDivByZeroFunction = class (TMyAulFunctions)
public
class function GetSignature : string; override;
procedure ExecuteFunction(aParams: TraParamList); override;
end;

TFltDivByZeroFunction = class (TMyAulFunctions)
public
class function GetSignature : string; override;
procedure ExecuteFunction(aParams: TraParamList); override;
end;

implementation

class function TMyAulFunctions.Category: String;
begin
result := 'AulRAPFunctions';
end;

class function TIntDivByZeroFunction.GetSignature : string;
begin
result := 'function IntDivByZero(X, Y: integer): single;';
end;

class function TFltDivByZeroFunction.GetSignature : String;
begin
result := 'function FltDivByZero(X, Y: single): single;';
end;


procedure TIntDivByZeroFunction.ExecuteFunction(aParams: TraParamList);
var
lx : integer;
ly : integer;
lresult : single;
begin
getparamvalue(0,lx);
getparamvalue(1,ly);
try
lresult := lx/ly;
except
on exception do lresult := 0;
end;
SetParamValue(2,lresult);
end;

procedure TFltDivByZeroFunction.ExecuteFunction(aParams: TraParamList);
var
lx : single;
ly : single;
lresult : single;
begin
getparamvalue(0,lx);
getparamvalue(1,ly);
try
lresult := lx/ly;
except
on exception do lresult := 0;
end;
SetParamValue(2,lresult);
end;

initialization
raRegisterFunction('IntDivByZero', TIntDivByZeroFunction);
raRegisterFunction('FltDivByZero', TFltDivByZeroFunction);

finalization
raUnRegisterFunction('IntDivByZero');
raUnRegisterFunction('FltDivByZero');
end.

Comments

  • edited July 2001
    I copied your code straight into a new unit in a new project.

    Running from Delphi, the exception is shown because Delphi debugging is on.
    However, when running the exe outside of Delphi, no exception is shown and
    it previews fine for me with 0 and non zero numbers as the divisor.

    If you are using a TppVariable, make sure its type is set correctly,
    otherwise you'll always get 0 for the result of the OnCalc event, no matter
    what is assigned to the Value parameter on the OnCalc.

    D6, RB 6, Win 2000.


    Cheers,

    Jim Bennett
    Digital Metaphors


This discussion has been closed.