Delphi Programmer's Resources/Examples

Passing variables to Report Smith:


{
  This sample code is presented as is.
  Although every reasonable effort has been
  made to insure the soundness of the example
  below, Idioma Software inc. makes no warranty
  of any kind with regard to this program sample
  either implicitly or explicitly.

  This program example may be freely distributed for the
  use of writing computer programs only. Any other use of
  this material requires written permission from Idioma Software inc.

  (c) 1997 Idioma Software inc. All rights reserved.
 }

unit Urptsmth;

interface

uses
  SysUtils, WinTypes, WinProcs, Messages, Classes, Graphics, Controls,
  Forms, Dialogs, Report;

type
  TfrmRptSmithTst = class(TForm)
    Report1: TReport;
    procedure FormClick(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  frmRptSmithTst: TfrmRptSmithTst;

implementation

{$R *.DFM}
{
 This example shows how to pass variables to ReportSmith
}

procedure TfrmRptSmithTst.FormClick(Sender: TObject);
var f : textfile;

begin
{This example assumes you have declared the variable RptVar as a report
variable in ReportSmith}

{Use the initial values property of the Report componant to pass a report variable}
{The syntax is as follows:}

Report1.InitialValues.Add('RptVar=');
{You will have problems passing the '<>' character as the '>' character
gets ReportSmith confused. Instead use something like '~=' and convert
using a ReportSmith macro}

{Also, there is a limit to the total size of parameters. If you need to pass
anything larger than about 256, you must use a temporary file and pass the
file name to ReportSmith. Then write a macro to read the information from the
file:}

AssignFile(f, 'ParmFile.txt');
rewrite(f);
write(f, 'Write the info to a file');
closefile(f);
Report1.InitialValues.Add('FileName=');

{The Run method runs the report}
Report1.Run;

end;

end.

 


 
 
 
 
 

Powered by
Guatemalan Dark Roast