unit Unit1;

{$mode objfpc}{$H+}

interface

uses
  Classes, SysUtils, FileUtil, lrQRCode, QRCode, LR_Class, LR_Desgn, LR_DBSet,
  LR_BarC, Forms, Controls, Graphics, Dialogs, StdCtrls, DBGrids, db, memds;

type

  { TForm1 }

  TForm1 = class(TForm)
    Button1: TButton;
    Button2: TButton;
    DataSource1: TDataSource;
    DBGrid1: TDBGrid;
    frBarCodeObject1: TfrBarCodeObject;
    frDBDataSet1: TfrDBDataSet;
    frDesigner1: TfrDesigner;
    frReport1: TfrReport;
    lrQRCode1: TlrQRCode;
    MemDataset1: TMemDataset;
    procedure Button1Click(Sender: TObject);
    procedure Button2Click(Sender: TObject);
    procedure FormCreate(Sender: TObject);
  private
    function ReportFileName:string;
  public

  end;

var
  Form1: TForm1;

implementation
uses LazUTF8, LazFileUtils;
{$R *.lfm}

{ TForm1 }

procedure TForm1.Button1Click(Sender: TObject);
var
  S: String;
begin
  S:=ReportFileName;
  if FileExistsUTF8(S) then
    frReport1.LoadFromFile(S);
  frReport1.ShowReport;
end;

procedure TForm1.Button2Click(Sender: TObject);
var
  S: String;
begin
  S:=ReportFileName;
  if FileExistsUTF8(S) then
    frReport1.LoadFromFile(S)
  else
    frReport1.FileName:=S;

  frReport1.DesignReport;
end;

procedure TForm1.FormCreate(Sender: TObject);
begin
  MemDataset1.Open;
  MemDataset1.AppendRecord([1, 'Hello world']);
  MemDataset1.AppendRecord([2, '123']);
  MemDataset1.AppendRecord([3, 'http://freepascacl.ru']);
end;

function TForm1.ReportFileName: string;
begin
  Result:=AppendPathDelim(ExtractFileDir(ParamStrUTF8(0))) + 'qrcode.lrf';
end;

end.

