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

Replace text in DBMemo

edited June 2009 in General
Hello,

I want to replace some Text in a DBMemo - but I can't find a strReplace
or something like that in function in the string functions.
How to do it?

Thanks,
greets ben

Comments

  • edited June 2009
    Hi Ben,

    I assume you are using RAP. RAP does not include a built-in string replace
    routine. This is something we will consider adding for a later release.

    Currently you can create a passthru function to preform the string replace
    in Delphi or use a combination of Delete, Insert, and Pos to achieve the
    same thing. See the RAP demos on how to create a passthru function.

    --
    Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com

    Best Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com
  • edited June 2009
    Hi Nick,

    thanks for your answer.
    I wanted to take a look at the demos, but on my installation there is no
    demo-folder.
    So I tried to reinstall report builder, but there was no option for
    installing the demos. How do I get them?

    Thank you!

    Nico Cizik (Digital Metaphors) schrieb:
  • edited June 2009
    Hi Nick,

    sorry for asking again, but I don't check it with the passthru function.
    I looked at the demo example and tried to modify the trim function in
    example "myRapFuncs0031".

    I don't really undestanding how to code the ExecuteFunction.
    Also, after compiling the project I get the error "Cannot compile
    signature for String function: StringReplace".

    Once more - thank you very much for you help!
    Greets,
    ben



    Code:

    unit myRapFuncs0031;

    interface

    uses
    SysUtils, Windows, Messages, Classes, Graphics, Controls,
    Forms, Dialogs, raFunc, ppRTTI;

    type
    TmyStringReplaceFunction = class (TraStringFunction)
    public
    procedure ExecuteFunction(aParams: TraParamList); override;
    class function GetSignature: String; override;
    end;

    implementation

    class function TmyStringReplaceFunction.GetSignature: String;
    begin
    Result := 'function StringReplace(const S, OldPattern, NewPattern:
    string; Flags: TReplaceFlags): string;';

    end; {class function, GetSignature}


    procedure TmyStringReplaceFunction.ExecuteFunction(aParams: TraParamList);
    var
    lsResult: String;
    S : string;
    OldPattern :string;
    NewPattern: string;
    Flags: TReplaceFlags;
    begin

    GetParamValue(0, S);
    GetParamValue(1, OldPattern);
    GetParamValue(2, NewPattern);
    GetParamValue(3, Flags);

    lsResult := StringReplace(S,OldPattern,NewPattern,Flags);

    SetParamValue(1, lsResult);
    end; {procedure, ExecuteFunction}


    initialization
    raRegisterFunction('StringReplace', TmyStringReplaceFunction);

    finalization
    raUnRegisterFunction('StringReplace');

    end.



    Nico Cizik (Digital Metaphors) schrieb:
  • edited June 2009
    Hi Benjamin,

    I do not believe RAP will recognize the TReplaceFlags type. Try sending an
    integer instead then based on that value assign the TReplaceFlags equivalent
    when calling StringReplace in Delphi.

    --
    Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com

    Best Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com
  • edited June 2009
    It is also possible to register an enumerated type with RAP using the
    raRegisterEnum routine so the TReplaceFlags type will be recognized. Take a
    look at the ppEnum.pas file for how we do this in ReportBuilder.

    --
    Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com

    Best Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com
  • edited July 2009
    Thanks for your help Nick, it works fine now.
    Greets, ben

    Nico Cizik (Digital Metaphors) schrieb:
This discussion has been closed.