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

Create RAP function

edited January 2015 in RAP
Hi,

Is there a way to create the following function in RAP?

function ScaleFromSmallFontsDimension(const X: Integer): Integer;
begin
Result := MulDiv(X, Screen.PixelsPerInch, SmallFontsPixelsPerInch);
end;

Comments

  • edited January 2015
    To clearify:

    The X stands for a new position of a control in RAP.
    Normally in RAP one would use:
    begin
    Label1.Left := 108;
    end;

    I would like to use:
    begin
    Label1.Left := CalcPixelsPerInch(108); // This value must be passed to
    the function. Might be any value.
    end;


    unit FunctionsUnitRAP;

    interface

    uses Forms, raFunc, ppRTTI, FunctiesUnit4;

    type
    TMyPixelsPerInch = class(TraSystemFunction)
    public
    class function category: String; override;
    end;

    TMyPixelsPerInchFunction = class(TMyPixelsPerInch)
    public
    procedure ExecuteFunction(aParams: TraParamList); override;
    class function GetSignature: String; override;
    class function HasParams: boolean; override;
    end;

    implementation

    uses Hoofdscherm;

    class function TMyPixelsPerInch.Category: string;
    begin
    result := 'Calculate PixelsPerInch';
    end;

    procedure TMyPixelsPerInchFunction.ExecuteFunction(aParams: TraParamList);
    begin
    // X is the value added in RAP.
    SetParamValue(0, ScaleFromSmallFontsDimension(X)); // <-- X should
    be passed by RAP
    end;

    class function TMyPixelsPerInchFunction.GetSignature: String;
    begin
    Result := 'function CalcPixelsPerInch : Integer;';
    end;

    class function TMyPixelsPerInchFunction.HasParams: boolean;
    begin
    Result := True; // <- This might be needed to be set to True in order
    to pass variable X ????
    end;

    initialization
    raRegisterFunction('CalcPixelsPerInch',TMyPixelsPerInchFunction);

    end.
  • edited January 2015
    Will this work?

    procedure TMyPixelsPerInchFunction.ExecuteFunction(aParams: TraParamList);
    var vInput : Integer;
    begin
    // X is the value added in RAP.
    GetParamValue(0, vInput);
    SetParamValue(1, ScaleFromSmallFontsDimension(vInput)); // <-- X should
    be passed by RAP
    end;

    class function TMyPixelsPerInchFunction.HasParams: boolean;
    begin
    Result := True;
    end;
  • edited January 2015
    Hi Stef,

    Try creating this routine in Delphi first, then create a passthru
    function for it. The basic rule of thumb is that if you can get it
    working in Delphi, it can work in RAP with passthru.

    Best Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com
This discussion has been closed.