Delphi's Variables

In the Delphi projects I use Delphi's Global Variables, ??it's posible to pass/go these variables to FR, (in a Report Title Band u other Band type)?.

In a lengthy previous topic, Samuray reply:

<span style='color:blue'>Nothing problem.
frVariables := anyvalue;
after use variable with name 'ANYVARNAME' in report.
</span>

But, I'm try with this method and d'ont work.

- frVariables it's a object of all frReport 's vars?

Sorry for my English, I try to explain better: I want to print (in Report Title Band and Page Header Band) some Global Delphi vars than I use in a Delphi form like: CompanyName, UserName, ComputerName and others ??How can I do it?

Thanks Again

Comments

  • SamuraySamuray Administrator
    edited 3:26AM
    Simple example
    Write in Delphi code:

    frReport1.LoadFromFile('mylikereport.frf');
    frVariables := 'MyCompanyName, Ltd.';
    frReport1.ShowReport;

    In report place memo on page and double click on memo by mouse.
    Print in memo:
    [COMPANY]

    After save (close) memo, save report with name 'mylikereport.frf' in project folder and try project to run.

    FAQ:
    2.25. How to pass a value to the report?

    There are several methods to do this. First is to use global object
    frVariables (defined in FR_Class unit):

    frVariables := 10;

    This code creates a new variable with 'My variable' name and value = 10.
    This method is best to pass static data to the report.

    Second method is to use the TfrReport.OnGetValue event. You can use this
    method to pass dynamic data, i.e. data that changes from record to record.

    procedure TForm1.frReport1GetValue(ParName: String; var ParValue: Variant);
    begin
    if ParName = 'MyField' then
    ParValue := Table1MyField.Value;
    end;

    Finally, third method is to define variable from dictionary programmatically:

    with frReport1.Dictionary do
    begin
    Variables := 'CustomerData.Customers."CustNo"';
    Variables := '10';
    end;

    (can I pass data from report to the program?)

    Use frVariables object. If you write the following code in any script:

    MyVariable := 10

    then in your program you can use this code to retrieve MyVariable value:
    v := frVariables;
  • edited 3:26AM
    Thanks Samurai!!!

    I understand it and that's work.

    Thanks Again
  • edited 3:26AM
    thanks for everything

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.