RAP WoY Function
Hi Guys,
Just starting out on this RAP stuff and I'm afraid my skills aren't up to it
yet.
I am trying to create a RAP Week of the Year function i.e. WoY(Date) to give
the Week #. I have taken the 'Trim()' example and tried to convert it.
I have the following which compiles into the application OK but when I go to
open it in 'Calc' it won't 'compile'
===============================================================================
unit myRapFuncs0037;
interface
uses
SysUtils, Windows, Messages, Classes, Graphics, Controls,
Forms, Dialogs, DateUtils, raFunc, ppRTTI;
type
TmyWoYFunction = class (TraDateTimeFunction)
public
procedure ExecuteFunction(aParams: TraParamList); override;
class function GetSignature: String; override;
end;
implementation
{------------------------------------------------------------------------------}
{ TmyWoYFunction.GetSignature }
class function TmyWoYFunction.GetSignature: String;
begin
Result := 'function WOY(const AValue: TDateTime): Word; overload;';
end; {class function, GetSignature}
{------------------------------------------------------------------------------}
{ TmyWoYFunction.ExecuteFunction }
procedure TmyWoYFunction.ExecuteFunction(aParams: TraParamList);
var
lsResult: Word;
lsDate: TDateTime;
begin
GetParamValue(0, lsDate);
lsResult := WeekofTheYear(lsDate);
SetParamValue(1, lsResult);
end; {procedure, ExecuteFunction}
initialization
raRegisterFunction('WoY', TmyWoYFunction);
finalization
raUnRegisterFunction('WoY');
end.
================================================================================
I have clearly not done it right.
I would appreciate it if someone could point out the error of my ways..
Regards & TIA,
Ian
Just starting out on this RAP stuff and I'm afraid my skills aren't up to it
yet.
I am trying to create a RAP Week of the Year function i.e. WoY(Date) to give
the Week #. I have taken the 'Trim()' example and tried to convert it.
I have the following which compiles into the application OK but when I go to
open it in 'Calc' it won't 'compile'
===============================================================================
unit myRapFuncs0037;
interface
uses
SysUtils, Windows, Messages, Classes, Graphics, Controls,
Forms, Dialogs, DateUtils, raFunc, ppRTTI;
type
TmyWoYFunction = class (TraDateTimeFunction)
public
procedure ExecuteFunction(aParams: TraParamList); override;
class function GetSignature: String; override;
end;
implementation
{------------------------------------------------------------------------------}
{ TmyWoYFunction.GetSignature }
class function TmyWoYFunction.GetSignature: String;
begin
Result := 'function WOY(const AValue: TDateTime): Word; overload;';
end; {class function, GetSignature}
{------------------------------------------------------------------------------}
{ TmyWoYFunction.ExecuteFunction }
procedure TmyWoYFunction.ExecuteFunction(aParams: TraParamList);
var
lsResult: Word;
lsDate: TDateTime;
begin
GetParamValue(0, lsDate);
lsResult := WeekofTheYear(lsDate);
SetParamValue(1, lsResult);
end; {procedure, ExecuteFunction}
initialization
raRegisterFunction('WoY', TmyWoYFunction);
finalization
raUnRegisterFunction('WoY');
end.
================================================================================
I have clearly not done it right.
I would appreciate it if someone could point out the error of my ways..
Regards & TIA,
Ian
This discussion has been closed.
Comments
Try removing the "overload" keyword from the declairation of the function
signature. Note that unless you build this into a design-time package and
install in into the IDE, your code will only compile at runtime.
--
Regards,
Nico Cizik
Digital Metaphors
http://www.digital-metaphors.com
Nico Cizik
Digital Metaphors
http://www.digital-metaphors.com
Thanks for the reply.
I removed the 'overload;' but I still get "Cannot compile signature for
DateTime function: WOY." at run time when select 'Language'.
Sorry, I don't understand what you are saying here.
Regards,
Ian
I believe the issue is the "word" type. Rap does not have a concept of this
type. Try using an Integer type instead and the routine should function
correctly.
class function TmyWoYFunction.GetSignature: String;
begin
Result := 'function WOY(const AValue: TDateTime): Integer';
end; {class function, GetSignature}
{------------------------------------------------------------------------------}
{ TmyWoYFunction.ExecuteFunction }
procedure TmyWoYFunction.ExecuteFunction(aParams: TraParamList);
var
liResult: Integer;
lDate: TDateTime;
begin
GetParamValue(0, lDate);
lsResult := WeekofTheYear(lDate);
SetParamValue(1, liResult);
end; {procedure, ExecuteFunction}
--
Regards,
Nico Cizik
Digital Metaphors
http://www.digital-metaphors.com
Nico Cizik
Digital Metaphors
http://www.digital-metaphors.com