Using "uses"

KelloucheKellouche Algeria
edited 3:07AM in FastReport 3.0
Hi,

I try to use the uses command like this
uses 'c:\source.pas';

procedure Memo80OnAfterData(Sender: TfrxComponent);
begin
  Memo80.Text := ExtractxMonthFromDate(Memo80.Value, True, True);
end;

of course, "source.pas" is in the c:\ target, when compiled i have this message error :
wrote:
identified redeclared:"Memo80OnAfterData
, so i have suspected the "souce.pas" but the memo80 is never declared in this file !

why resolved this error ?

thanks for all.

Comments

  • edited 3:07AM
    Try this convention, where you can manipulate Sender properties:
    procedure Memo2OnBeforePrint(Sender: TfrxComponent);
    begin
      TfrxMemoView(Sender).Color := clRed;
      TfrxMemoView(Sender).Text  := ExtractxMonthFromDate( TfrxMemoView(Sender).Value, True, True);
    end;
    
    Mick

    PS.
    How do you make it that CodeBox doesn't contain too many emply lines?
  • KelloucheKellouche Algeria
    edited 3:07AM
    Mick.pl wrote: »
    Try this convention, where you can manipulate Sender properties:
    procedure Memo2OnBeforePrint(Sender: TfrxComponent);
    begin
      TfrxMemoView(Sender).Color := clRed;
      TfrxMemoView(Sender).Text  := ExtractxMonthFromDate( TfrxMemoView(Sender).Value, True, True);
    end;
    
    Mick

    PS.
    How do you make it that CodeBox doesn't contain too many emply lines?

    hi Mick
    i have the same error after applicated your proposition !!
    i would like an example of the using of "uses" command, is there possible ?
    i havent understund your PS (i'am so bad in english > )
  • edited 3:07AM
    Well, I wasn't enough clever to see that it was Memo80OnAfterData that caused an error message from your compiler [img]style_emoticons/<#EMO_DIR#>/sad.gif" style="vertical-align:middle" emoid=":(" border="0" alt="sad.gif" /> As at the moment I am NOT Delphi user, so my knowledge of it is very short. Try to add all source of[/img]ExtractxMonthFromDate to the same file (fr3) where you have
    procedure SysMemo27OnAfterData(Sender: TfrxComponent);
    var
       res : string;
    begin
      SysMemo27.Text :=    SysMemo14.Value + SysMemo15.Value + SysMemo16.Value +
                           SysMemo18.Value + SysMemo19.Value + SysMemo20.Value +
                           SysMemo21.Value + SysMemo22.Value + SysMemo23.Value +
                           SysMemo24.Value + SysMemo25.Value + SysMemo26.Value;
      try
        res := Format('%2.0n', [SysMemo27.Text]); // this does not work
        SysMemo27.Text := res;
      except
        ShowMessage('Erreur de formatage');
      end
    end;
    

    I mean - you do NOT have to compile ExtractxMonthFromDate - you can define it in FR script of your report. If you need to compile your new functions you must do some more work to let FR engine see and accept your user functions like its own (e.g. Format(), VarToStr(), and so on).

    So if you apply your source of new function to FR script and it will work then you will NOT have to compile it and get error msg.

    Mick
  • KelloucheKellouche Algeria
    edited May 2011
    no no Mick, there is no report with Delphi !!
    the situation is like this : i have 4 reports, each report have its code page, i would like to call the ExtractMonthFromDate function from an external unit witch i define in "source.pas"
    logically i will do this in the header of code page for eatch report
    wrote:
    uses "c:\source.pas"
    but when i do "F9" i have the message error !!

    PS : when i put the function ExtractMonthFromDate in the same page code, the previsualisation is correctly executed.
  • edited 3:07AM
    So we are at home now [img]style_emoticons/<#EMO_DIR#>/smile.gif" style="vertical-align:middle" emoid=":)" border="0" alt="smile.gif" /> I'm not sure if FR 3 accepts[/img]uses as Delphi compilers do.

    FR 4 comes with so called report inheritance and this functionality seems to be a solution for having pieces of the same code or layout for several reports kept in ONE template.

    If you don't find any solution to have your functions defined once anywhere, then you will have to Copy & Paste this piece of FR script to each report you want to use these functions in [img]style_emoticons/<#EMO_DIR#>/sad.gif" style="vertical-align:middle" emoid=":(" border="0" alt="sad.gif" /> But I think that even with these[/img]copied & pasted function your reports will have less lines of script [img]style_emoticons/<#EMO_DIR#>/wink.gif" style="vertical-align:middle" emoid=";)" border="0" alt="wink.gif" /> Mick[/img]
  • KelloucheKellouche Algeria
    edited 3:07AM
    Mick.pl wrote: »
    So we are at home now >I'm not sure if FR 3 accepts uses as Delphi compilers do.

    FR 4 comes with so called report inheritance and this functionality seems to be a solution for having pieces of the same code or layout for several reports kept in ONE template.

    If you don't find any solution to have your functions defined once anywhere, then you will have to Copy & Paste this piece of FR script to each report you want to use these functions in [img]style_emoticons/<#EMO_DIR#>/sad.gif" style="vertical-align:middle" emoid=":(" border="0" alt="sad.gif" /> But I think that even with these[/img]copied & pasted function your reports will have less lines of script [img]style_emoticons/<#EMO_DIR#>/wink.gif" style="vertical-align:middle" emoid=";)" border="0" alt="wink.gif" /> Mick[/img]

    i think it accepts because he passed succesful the declaration 'uses c:\source.pas'
    for the alternative solution, yes adopte this solution but its not the best method

    i regard other ways...
  • edited 3:07AM
    Attach an example of your report (fr3 file), or any similar sample, where you use "uses 'c:\source.pas'" and I'll have a look at it.

    Mick
  • KelloucheKellouche Algeria
    edited 3:07AM
    Mick.pl wrote: »
    Attach an example of your report (fr3 file), or any similar sample, where you use "uses 'c:\source.pas'" and I'll have a look at it.

    Mick

    oki my friend.
    thanks.
  • edited 3:07AM
    My Designer has no components for your Database, but it doesn't matter.
    I see there is NOT Memo80OnAfterData procedure in code page of your report.
    And Memo80 has no events.

    Mick
  • KelloucheKellouche Algeria
    edited 3:07AM
    Mick.pl wrote: »
    My Designer has no components for your Database, but it doesn't matter.
    I see there is NOT Memo80OnAfterData procedure in code page of your report.
    And Memo80 has no events.

    Mick

    exactly, so why i have that message error ?
  • gpigpi
    edited 3:07AM
    Try to comment
    {interface
    
    function ReplaceIfBlanc(ch, t : char) : string;
    function ExtractxMonthFromDate(TD : TDateTime; Mois_Texte, MAJUSCULE : boolean): string;
    
    
    implementation}
    
  • KelloucheKellouche Algeria
    edited 3:07AM
    gpi wrote: »
    Try to comment
    {interface
    
    function ReplaceIfBlanc(ch, t : char) : string;
    function ExtractxMonthFromDate(TD : TDateTime; Mois_Texte, MAJUSCULE : boolean): string;
    
    
    implementation}
    

    Hi gpi
    conventionaly a pascal unit has this declaration
    interface
    implementation

    in the interface we make the definition of function or procedure and if we want the public variables
    in impmentation we defined the function and procedure declared in the interface part

    so, i have made my all users functions in a "source.pas" and i would like called them in the page code of an FR3 rerport.
    in the "FastReport 3 user manuel " script chapter they said :
    gpi wrote: »
    Structure of a script
    Script???s structure depends on the language you use; however there are some
    common elements. They are the script???s title, body, and the main procedure, which will
    be executed when the report runs. Below there are examples of the scripts for all four
    supported languages:
    PascalScript???s structure:
    #language PascalScript // optional
    program MyProgram; // optional
    // the ???uses??? chapter should be located before any other chapter
    uses 'unit1.pas', 'unit2.pas';
    var // the ???variables??? chapter can be placed anywhere
    i, j: Integer;
    const // ???constants??? chapter
    pi = 3.14159;
    procedure p1; // procedures and functions
    var
    i: Integer;
    procedure p2; // nested procedure
    begin
    end;
    begin
    end;
    begin // main procedure.
    end.

    perhaps this doest not worked with FR3 >
  • edited 3:07AM
    Well we all missed the real meaning of the error message >
    wrote:
    identified redeclared:"Memo80OnAfterData
    What means that Memo80OnAfterData seems (for FR script processor) to be declared twice.

    I've made some tests both with FR4 (4.10.14) and FR3 (C/S demo 3.15a). And while testing I tried to write as simple as possible script to avoid any complication. My tests have ended with succes - so uses work in general. Maybe it doesn't when script is not so simple.
    Have a look at attached files.

    identified [b]redeclared[/b]:"Memo80OnAfterData
    
  • gpigpi
    edited 3:07AM
    wrote:
    exactly, so why i have that message error ?
    But in your first message you wrote:
    uses 'c:\source.pas';
    
    procedure Memo80OnAfterData(Sender: TfrxComponent);
    begin
      Memo80.Text := ExtractxMonthFromDate(Memo80.Value, True, True);
    end;
    
    Did you changed your report template?
    Attach small demo project with problem here
  • KelloucheKellouche Algeria
    edited May 2011
    gpi wrote: »
    gpi wrote: »
    exactly, so why i have that message error ?
    But in your first message you wrote:
    uses 'c:\source.pas';
    
    procedure Memo80OnAfterData(Sender: TfrxComponent);
    begin
      Memo80.Text := ExtractxMonthFromDate(Memo80.Value, True, True);
    end;
    
    Did you changed your report template?
    Attach small demo project with problem here

    no i have not change my report template.
    i have attached an example in post #9.

    thanks for all.
  • gpigpi
    edited 3:07AM
    Attach small demo project with problem here
  • KelloucheKellouche Algeria
    edited May 2011
    gpi wrote: »
    Attach small demo project with problem here

    oki
    here is a very very simple project.
  • KelloucheKellouche Algeria
    edited May 2011
    Kellouche wrote: »
    Kellouche wrote: »
    Attach small demo project with problem here

    oki
    here is a very very simple project.

    look at this articl (part Structure of a script) in the official site of FR
  • edited 3:07AM
    I have few comments to your examples:

    1. There is no Memo10 on a Page. There is Memo1
    2. OnAfterPrint event may be too late too change contents of TfrxMemoView
    3. There is no replacement instruction to change Memo.Text, like Memo.Text := ReplaceIfBlank(...)
    4. Did you have any errors while running (F9) this report?

    I attach 2 file - your examples with small lifting:
    1. Added box around Memo to be sure that anything was printed
    2. Commented part of simple_source.pas (implementation etc)
    3. Added begin / end. at the end of file.

    [img]style_emoticons/<#EMO_DIR#>/smile.gif" style="vertical-align:middle" emoid=":)" border="0" alt="smile.gif" /> Mick[/img]
  • KelloucheKellouche Algeria
    edited 3:07AM
    Hi

    i think the error was in the interface
    i have do the same with the pascal unit watch has an anterface and implementation section but in the script pascal of FR it does not supported
    i have remove the interface section and the project will word perfectly

    all my thanks to Mick and gpi
  • KelloucheKellouche Algeria
    edited May 2011
    Hi

    I try to do this
    wrote:
    uses '\\PC-DEM-HADRI\data\source.pas';'
    the file is alredy exists in this post but when executed i have this message error is "BEGIN expected"

    can i have an example for how can i call a script file from another PC ?
  • edited 3:07AM
    Informative post. Maybe I'll try this one.
  • KelloucheKellouche Algeria
    edited 3:07AM
    Jenny Ledd wrote: »
    Informative post. Maybe I'll try this one.

    wait and see >

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.