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

Enumerated type as a parameter in pass-trough function

edited April 2004 in RAP
Hi RB team,

I registered some enumerated type in RAP OK (it appeared in RAP data types
list). Now I want to call some pass-through function and pass parameter,
which is type of enumerated :
MyRapFunction(aMyType:TMyEnumeratedType)

I compiled that function in Delphi OK.

When I open Calc TAB in Report Designer and then LANGUAGE tab, i got error
message:
"Could not compile program: MyRapFunction".
If I pass a parameter of any RAP default data type it works OK.

Then I tried to add Delphi's ORD function to RAP to get around this problem.
But I realised, that I can't do that because RAP doesn't have ORDINAL data
type registered.

Well, I think I could survive without my enumerated types in RAP, but it
would be better to have that functionality.

Cheers,
Dmitry

Comments

  • edited April 2004

    I created a simple example using RB 7.03 and did not encounter any issues. I
    defined a TmyEnumType and a RAP pass-thru function called ShowEnumName


    1. Here is my RAP event-handler code that test passing a custom enum type as
    a parameter:

    procedure GlobalOnCreate;
    var
    lEnum: TmyEnumType;
    begin
    lEnum := EnumOne;
    ShowEnumName(lEnum);
    end;


    2. And here is my Delphi code that defines the TmyEnumType and the RAP
    pass-thru function called ShowEnumName.


    unit myRAPFuncs;

    interface

    uses
    Dialogs,
    ppRTTI, raFunc, ppEnum;

    type

    TmyEnumType = (EnumOne, EnumTwo, EnumThree);

    TmyTestEnumFunctions = class (TraSystemFunction)
    public
    {Override Category to return a new category string}
    class function Category: String; override;
    end;

    TmyTestEnumParameterFunction = class (TmyTestEnumFunctions)
    public
    procedure ExecuteFunction(aParams: TraParamList); override;
    class function GetSignature: String; override;
    class function HasParams: Boolean; override;
    class function IsFunction: Boolean; override;
    end;


    implementation

    { TmyTestEnumFunctions }

    class function TmyTestEnumFunctions.Category: String;
    begin
    Result := 'myTestEnumFunctions';
    end;

    { TmyTestEnumParameterFunction }

    class function TmyTestEnumParameterFunction.GetSignature: String;
    begin
    Result := 'procedure ShowEnumName(aEnum: TMyEnumType);'
    end;

    class function TmyTestEnumParameterFunction.HasParams: Boolean;
    begin
    Result := True;
    end;

    class function TmyTestEnumParameterFunction.IsFunction: Boolean;
    begin
    Result := False;
    end;

    procedure TmyTestEnumParameterFunction.ExecuteFunction(aParams:
    TraParamList);
    var
    lEnumType: TMyEnumType;
    lsEnumName: String;
    begin

    GetParamValue(0, lEnumType);

    lsEnumName := raEnumNameForValue('TMyEnumType', Ord(lEnumType));

    ShowMessage(lsEnumName);


    end;



    initialization
    raRegisterEnum('TMyEnumType', TypeInfo(TMyEnumType));
    raRegisterFunction('ShowEnumName', TmyTestEnumParameterFunction);

    finalization
    raUnRegisterFunction('ShowEnumName');


    end.





    --
    Nard Moseley
    Digital Metaphors Corporation
    http://www.digital-metaphors.com


    Best regards,

    Nard Moseley
    Digital Metaphors
    www.digital-metaphors.com
This discussion has been closed.