Various Fr2.5 to Fr4 Questions

EPMLEPML UK
edited 4:30PM in FastReport 4.0
(Using D7 Ent)

Hi All,

First post here!

Sorry if my questions have been asked a million times before - have tried looking in the forum and the user manual for Fr4 but I am currently stuck on a couple of lines of code migrating a Fr2.5 report (that I have inherited) over to Fr4, both of which I am new to.

I successfully used the frx2xto30.pas mechanism to convert most of the report correctly (had to re-align objects after) and started to read about the changes to the script expression and MemoView expressions. I tried to make the changes but nothing I seem to do works! Can anyone help me out with converting my Fr2.5 code to Fr4 code below?

In my first Fr2.5 MemoView to convert I have the following:
[IF([IB_Query2."AMOUNT"] < 0,[IB_Query2."AMOUNT"], '')]

which I tried converting to:
[IF (<frxIBODataset1."AMOUNT"> < 0,<frxIBODataset1."AMOUNT">, '')]

but it does not work [img]style_emoticons/<#EMO_DIR#>/sad.gif" style="vertical-align:middle" emoid=":(" border="0" alt="sad.gif" /> Next I have 2 OnBeforePrint procedures that have been migrated to the Fr4 Designer Code page... In Fr2.5 I have the following code for the first one: (Balance is showing as a Variable in Fr4)[/img]
begin
  Balance := Balance + [IB_Query2."AMOUNT"];
end

which I tried converting to:
procedure MasterData1OnBeforePrint(Sender: TfrxComponent);
begin
  with MasterData1, Engine do
  begin
    <Balance> := <Balance> + <frxIBODataset1."AMOUNT">;
  end;
end;

but it too does not work [img]style_emoticons/<#EMO_DIR#>/sad.gif" style="vertical-align:middle" emoid=":(" border="0" alt="sad.gif" /> And for the second one I have tried converting: (Page_Balance is showing as a Variable in Fr4)[/img]
begin
  Page_Balance := Page_Balance + SUM([IB_Query2."AMOUNT"]);
end

to:
procedure Memo14OnBeforePrint(Sender: TfrxComponent);
begin
  with Memo14, Engine do
  begin
    <Page_Balance> := <Page_Balance> + SUM(<frxIBODataset1."AMOUNT">);
  end;
end;

once again, getting errors when trying to preview or run!

Can anyone show me how my simple code needs to be converted to the new Fr4 way of doing things please? [img]style_emoticons/<#EMO_DIR#>/smile.gif" style="vertical-align:middle" emoid=":)" border="0" alt="smile.gif" /> Many thanks for any help in advance.[/img]

Comments

  • gordkgordk St.Catherines On. Canada.
    edited 4:30PM
    [IIF(<Customers."Company"> ='',<Customers."Addr1">,<Customers."Addr2">)]

    assuming balance is a typed var declared at the start of the codepage
    <Balance> := <Balance> + <frxIBODataset1."AMOUNT">;
    becomes
    Balance := Balance + <frxIBODataset1."AMOUNT">;

    this one is a bit differrent [] should be outer, fieldvalues <>

    Page_Balance := Page_Balance + SUM([IB_Query2."AMOUNT"]);
    this becomes
    Page_Balance := Page_Balance + [SUM(<IB_Query2."AMOUNT">,bandname,flag)];
    but you must follow aggregate rules, read the usermanual on aggregates.

    in Summary
    if a variable is a typed variable no braces necessary
    if a data field value in script use < >
    if using a categorized variable use get and set methods
  • EPMLEPML UK
    edited November 2009
    gordk wrote: »
    [IIF(<Customers."Company"> ='',<Customers."Addr1">,<Customers."Addr2">)]

    assuming balance is a typed var declared at the start of the codepage
    <Balance> := <Balance> + <frxIBODataset1."AMOUNT">;
    becomes
    Balance := Balance + <frxIBODataset1."AMOUNT">;

    this one is a bit differrent [] should be outer, fieldvalues <>

    Page_Balance := Page_Balance + SUM([IB_Query2."AMOUNT"]);
    this becomes
    Page_Balance := Page_Balance + [SUM(<IB_Query2."AMOUNT">,bandname,flag)];
    but you must follow aggregate rules, read the usermanual on aggregates.

    in Summary
    if a variable is a typed variable no braces necessary
    if a data field value in script use < >
    if using a categorized variable use get and set methods


    Hi gordk,

    Thanks for the help!

    I managed to convert your code:

    [IIF(<Customers."Company"> ='',<Customers."Addr1">,<Customers."Addr2">)]

    to:

    [IIF(<frxIBODataset1."AMOUNT"> < 0,<frxIBODataset1."AMOUNT">, '')]

    for my needs and that works great! [img]style_emoticons/<#EMO_DIR#>/smile.gif" style="vertical-align:middle" emoid=":)" border="0" alt="smile.gif" /> However, I am still having problems with the seconds part... I changed: procedure MasterData1OnBeforePrint(Sender: TfrxComponent); begin with MasterData1, Engine do begin <Balance> := <Balance> + <frxIBODataset1."AMOUNT">; end; end; to: procedure MasterData1OnBeforePrint(Sender: TfrxComponent); begin with MasterData1, Engine do begin Balance := Balance + <frxIBODataset1."AMOUNT">; end; end; and I get an error... Undeclared identifier: 'Balance'. As I mentioned before, Balance is a Variable declared in my Fr4 report in the Variables Tab (within the tree above the System Variables) on the right side of the report. Is this known as a categorised variable? Am I missing something else? I get the same error with the second piece of code you showed me with the Page_Balance Variable which is also listed in the Variables Tab meaning it must be a categorised variable too. Hope you can help me with the final part. Many thanks again![/img]
  • gordkgordk St.Catherines On. Canada.
    edited 4:30PM
    if your variable is a categorized variable in the variable list
    you must use set methods in code.
    Set('Balance',(<Balance> + 10));
    if it is a typed variable declared at the top of the code page it is global and available to all procedures.
    ie
    var
    Balance : extended;
    begin
    balance := 0; // initialize here or elsewhere before it is used in a memo.
    //BTW this is the first block processed when a report starts.
    end.
    then this is valid
    Balance := Balance + <frxIBODataset1."AMOUNT">;

    typed variables can also be local (declared within a procedure);
  • EPMLEPML UK
    edited 4:30PM
    gordk wrote: »
    if your variable is a categorized variable in the variable list
    you must use set methods in code.
    Set('Balance',(<Balance> + 10));
    if it is a typed variable declared at the top of the code page it is global and available to all procedures.
    ie
    var
    Balance : extended;
    begin
    balance := 0; // initialize here or elsewhere before it is used in a memo.
    //BTW this is the first block processed when a report starts.
    end.
    then this is valid
    Balance := Balance + <frxIBODataset1."AMOUNT">;

    typed variables can also be local (declared within a procedure);

    Thanks again gordk for your invaluable help!

    I have my categorised Balance Variable working now with:

    Set('Balance',(<Balance> + <frxIBODataset1."AMOUNT">));

    but I still have one more issue with my categorised Page_Balance Variable...

    I have now tried:

    Set('Page_Balance',(<Page_Balance> + [SUM(<frxIBODataset1."AMOUNT">), MasterData1]));

    but I am getting an 'Invalid variant operation' error showing.

    As a test, Set('Page_Balance',(<Page_Balance> + 10)); is working but the version above using the SUM function isnt.

    Can you help me format "Set('Page_Balance',(<Page_Balance> + [SUM(<frxIBODataset1."AMOUNT">), MasterData1]));" correctly please?

    Kind regards!
  • gordkgordk St.Catherines On. Canada.
    edited 4:30PM
    this one will become tricker depending upon where the memo showing page balance is located.
    ie page footer, group footer, or other footer read the notes in the manuals about aggregate function peculiarities(must be used in correct footers, and not available until after use). Generally read the programmers manual as working from delphi and the users manual as working inside the report.
    obviously for pagebalance you need to zero it probably in the oap of a footer or in obp of page header, then do your summing in the oap or oad event of an object in the masterdataband,
    just as you did with your other sum no aggregate function needed.

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.