Changing memo's value before print

mvemve
edited 2:32AM in FastReport 3.0
Hi!

I'd like to print on matrix printer, but i have to change some special hungarian characters after loading from database but, before printed on the dot printer to make readable my printed data.

I did the following:

function Csere (Mit : string) : String;
var I : integer;
begin
for I := 1 to length(Mit) do
case Mit of
'Ő' : Mit := 'ő';
'Ű' : Mit := 'ű';
end;
Result := Mit;
end;

procedure Memo1OnBeforePrint(Sender: TfrxComponent);
begin
Memo1.Memo.Text := Csere(Memo1.Memo.Text);
end;


It's not working....

I try to place the call of 'Csere' function in Master data onBeforePrint event, but it isn't working too.

if I say in 'Csere' function Result := 'A', then it's working, I see the 'A' characters on the preview.

but if I say Result := IntToStr(Length(Mit)); then I see a wrong number (and same in all lines), for example 65, however the length of data is differnet in each line(from 1 to 10 chars).

It looks like when the onbeforeprint event is running not the correct data is in the Memo1.Memo.Text;

How can I solve this problem?

Thanks!

Comments

  • mvemve
    edited 2:32AM
    Any idea from anyone? ;)
  • edited 2:32AM
    Memo1.Memo.Text := Csere(Memo1.Memo.Text); - it is wrong call, you need try - Memo1.Text := Csere(Memo1.Text);
  • mvemve
    edited 2:32AM
    wrote:
    Memo1.Memo.Text := Csere(Memo1.Memo.Text); - it is wrong call, you need try - Memo1.Text := Csere(Memo1.Text);
    Hi Den!

    Thanks, but it's not working too ;)

    Something else? ;)

  • edited 2:32AM
    My function:

    function Convert(Str:String):String;
    var i:integer;
    begin
    for i:=0 to length(Str)-1 do
    case Str of
    'a': Str:= 'A';
    'f': Str:= 'F';
    end;
    Result := Str;
    end;

    procedure Memo2OnBeforePrint(Sender: TfrxComponent);
    begin
    Memo2.Text:= Convert(Memo2.text);

    end;
    It is work!
  • mvemve
    edited 2:32AM
    wrote:
    My function:

    function Convert(Str:String):String;
    var i:integer;
    begin
    for i:=0 to length(Str)-1 do
    case Str of
    'a': Str:= 'A';
    'f': Str:= 'F';
    end;
    Result := Str;
    end;

    procedure Memo2OnBeforePrint(Sender: TfrxComponent);
    begin
    Memo2.Text:= Convert(Memo2.text);

    end;
    It is work!
    Den! Tanks!

    How do you test it? With a 'fix' text in the memo1 or data from dataset?
    I realised something. When I used 'fix' text for example: I hope this will be ok! then the function change the letters well, but when I'd like to read this text from database (firebird) memo1.text contains the 'dataset_name."field_name"' string, not the data from dataset, so I can't change anything....

    How can I catch that time when the finally text is in the memo.text? Not in onbeforeprint event???

    ;)
  • mvemve
    edited 2:32AM
    mve wrote:
    How can I catch that time when the finally text is in the memo.text? Not in onbeforeprint event???
    I found the solution.

    OnAfterData event.

    but why? ;)

    Thank you Den, it works!

    ;)
  • edited 2:32AM
    >>but why?

    In the help about OnAfterData event:
    "The name of the script routine that will be called after the object gets data."

    In the help about OnBeforePrint event:
    "The name of the script routine that will be called before the object is handled."
    ;)

Leave a Comment

Rich Text Editor. To edit a paragraph's style, hit tab to get to the paragraph menu. From there you will be able to pick one style. Nothing defaults to paragraph. An inline formatting menu will show up when you select text. Hit tab to get into that menu. Some elements, such as rich link embeds, images, loading indicators, and error messages may get inserted into the editor. You may navigate to these using the arrow keys inside of the editor and delete them with the delete or backspace key.