creating a Pass-through function
Hi,
I'm trying to create a Pass-through Function that can be used at design
time.
The following is my code that I'm installing as a Package. The code compiles
and the Package installs, but it's crashing ReportBuilder.
Thank you,
Randy
***********************************
unit AulRapFunctions;
interface
uses Forms, raFunc, ppRTTI, sysutils;
type
TMyAulFunctions = class (TraSystemFunction)
public
class function Category: String; override;
end;
TAulFunctions = class (TMyAulFunctions)
public
function IntDivByZero(X, Y: integer): single;
function FltDivByZero(X, Y: single): single;
end;
implementation
class function TMyAulFunctions.Category: String;
begin
result := 'AulRAPFunctions';
end;
function TAulFunctions.IntDivByZero(X, Y: integer): single;
begin
try
result := X/Y;
except
on exception do Result := 0;
end;
end;
function TAulFunctions.FltDivByZero(X, Y: single): single;
begin
try
result := X/Y;
except
on exception do Result := 0;
end;
end;
initialization
raRegisterFunction('AulRAPFunctions', TAulFunctions);
end.
****************************************************
I'm trying to create a Pass-through Function that can be used at design
time.
The following is my code that I'm installing as a Package. The code compiles
and the Package installs, but it's crashing ReportBuilder.
Thank you,
Randy
***********************************
unit AulRapFunctions;
interface
uses Forms, raFunc, ppRTTI, sysutils;
type
TMyAulFunctions = class (TraSystemFunction)
public
class function Category: String; override;
end;
TAulFunctions = class (TMyAulFunctions)
public
function IntDivByZero(X, Y: integer): single;
function FltDivByZero(X, Y: single): single;
end;
implementation
class function TMyAulFunctions.Category: String;
begin
result := 'AulRAPFunctions';
end;
function TAulFunctions.IntDivByZero(X, Y: integer): single;
begin
try
result := X/Y;
except
on exception do Result := 0;
end;
end;
function TAulFunctions.FltDivByZero(X, Y: single): single;
begin
try
result := X/Y;
except
on exception do Result := 0;
end;
end;
initialization
raRegisterFunction('AulRAPFunctions', TAulFunctions);
end.
****************************************************
This discussion has been closed.
Comments
new class. For example, this is the declaration for the TraStringFunction
class, along with two of the methods of the class, Copy and Delete:
{ TraStringFunction }
TraStringFunction = class(TraSystemFunction)
public
class function Category: String; override;
end; {class, TraStringFunction}
{ TraCopyFunction }
TraCopyFunction = class(TraStringFunction)
public
class function GetSignature: String; override;
procedure ExecuteFunction(aParams: TraParamList); override;
end; {class, TraCopyFunction}
{ TraDeleteFunction }
TraDeleteFunction = class(TraStringFunction)
public
class function GetSignature: String; override;
class function IsFunction: Boolean; override;
procedure ExecuteFunction(aParams: TraParamList); override;
end; {class, TraDeleteFunction}
{---------------------------------------------------------------------------
---}
{ TraStringFunction.Category }
class function TraStringFunction.Category: String;
begin
Result := ppLoadStr(975); {'String'}
end; {class function, Category}
{---------------------------------------------------------------------------
---}
{ TraCopyFunction.GetSignature }
class function TraCopyFunction.GetSignature: String;
begin
Result := 'function Copy(S: String; Index, Count: Integer): String;';
end; {class function, GetSignature}
{---------------------------------------------------------------------------
---}
{ TraCopyFunction.ExecuteFunction }
procedure TraCopyFunction.ExecuteFunction(aParams: TraParamList);
var
lsString: String;
liIndex: Integer;
liCount: Integer;
lsResult: String;
begin
GetParamValue(0, lsString);
GetParamValue(1, liIndex);
GetParamValue(2, liCount);
lsResult := Copy(lsString, liIndex, liCount);
SetParamValue(3, lsResult);
end; {procedure, ExecuteFunction}
{---------------------------------------------------------------------------
---}
{ TraDeleteFunction.GetSignature }
class function TraDeleteFunction.GetSignature: String;
begin
Result := 'procedure Delete(var S: String; Index, Count: Integer);';
end; {class function, GetSignature}
{---------------------------------------------------------------------------
---}
{ TraDeleteFunction.IsFunction }
class function TraDeleteFunction.IsFunction: Boolean;
begin
Result := False;
end; {class function, IsFunction}
{---------------------------------------------------------------------------
---}
{ TraDeleteFunction.ExecuteFunction }
procedure TraDeleteFunction.ExecuteFunction(aParams: TraParamList);
var
lsString: String;
liIndex: Integer;
liCount: Integer;
begin
GetParamValue(0, lsString);
GetParamValue(1, liIndex);
GetParamValue(2, liCount);
Delete(lsString, liIndex, liCount);
SetParamValue(0, lsString);
end; {procedure, ExecuteFunction}
Cheers,
Jim Bennett
Digital Metaphors
http://www.digital-metaphors.com
info@digital-metaphors.com