You've already forked lazarus-ccr
systools: Add code pattern and text data units (plus demos)
git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@6147 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
83
components/systools/examples/data_merge/datamerg.lpi
Normal file
83
components/systools/examples/data_merge/datamerg.lpi
Normal file
@@ -0,0 +1,83 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<CONFIG>
|
||||
<ProjectOptions>
|
||||
<Version Value="11"/>
|
||||
<PathDelim Value="\"/>
|
||||
<General>
|
||||
<Flags>
|
||||
<UseDefaultCompilerOptions Value="True"/>
|
||||
</Flags>
|
||||
<SessionStorage Value="InProjectDir"/>
|
||||
<MainUnit Value="0"/>
|
||||
<Title Value="datamerg"/>
|
||||
<Scaled Value="True"/>
|
||||
<ResourceType Value="res"/>
|
||||
<UseXPManifest Value="True"/>
|
||||
<XPManifest>
|
||||
<DpiAware Value="True"/>
|
||||
</XPManifest>
|
||||
<Icon Value="0"/>
|
||||
</General>
|
||||
<BuildModes Count="1">
|
||||
<Item1 Name="Default" Default="True"/>
|
||||
</BuildModes>
|
||||
<PublishOptions>
|
||||
<Version Value="2"/>
|
||||
</PublishOptions>
|
||||
<RunParams>
|
||||
<FormatVersion Value="2"/>
|
||||
<Modes Count="0"/>
|
||||
</RunParams>
|
||||
<RequiredPackages Count="2">
|
||||
<Item1>
|
||||
<PackageName Value="laz_systools"/>
|
||||
</Item1>
|
||||
<Item2>
|
||||
<PackageName Value="LCL"/>
|
||||
</Item2>
|
||||
</RequiredPackages>
|
||||
<Units Count="2">
|
||||
<Unit0>
|
||||
<Filename Value="datamerg.lpr"/>
|
||||
<IsPartOfProject Value="True"/>
|
||||
<UnitName Value="DataMerg"/>
|
||||
</Unit0>
|
||||
<Unit1>
|
||||
<Filename Value="datamrg0.pas"/>
|
||||
<IsPartOfProject Value="True"/>
|
||||
<HasResources Value="True"/>
|
||||
</Unit1>
|
||||
</Units>
|
||||
</ProjectOptions>
|
||||
<CompilerOptions>
|
||||
<Version Value="11"/>
|
||||
<PathDelim Value="\"/>
|
||||
<Target>
|
||||
<Filename Value="datamerg"/>
|
||||
</Target>
|
||||
<SearchPaths>
|
||||
<IncludeFiles Value="$(ProjOutDir)"/>
|
||||
<UnitOutputDirectory Value="lib\$(TargetCPU)-$(TargetOS)"/>
|
||||
</SearchPaths>
|
||||
<Linking>
|
||||
<Options>
|
||||
<Win32>
|
||||
<GraphicApplication Value="True"/>
|
||||
</Win32>
|
||||
</Options>
|
||||
</Linking>
|
||||
</CompilerOptions>
|
||||
<Debugging>
|
||||
<Exceptions Count="3">
|
||||
<Item1>
|
||||
<Name Value="EAbort"/>
|
||||
</Item1>
|
||||
<Item2>
|
||||
<Name Value="ECodetoolError"/>
|
||||
</Item2>
|
||||
<Item3>
|
||||
<Name Value="EFOpenError"/>
|
||||
</Item3>
|
||||
</Exceptions>
|
||||
</Debugging>
|
||||
</CONFIG>
|
||||
46
components/systools/examples/data_merge/datamerg.lpr
Normal file
46
components/systools/examples/data_merge/datamerg.lpr
Normal file
@@ -0,0 +1,46 @@
|
||||
(* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is TurboPower SysTools
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* TurboPower Software
|
||||
*
|
||||
* Portions created by the Initial Developer are Copyright (C) 1996-2002
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** *)
|
||||
|
||||
{$IFDEF FPC}
|
||||
{$mode DELPHI}
|
||||
{$ENDIF}
|
||||
|
||||
program DataMerg;
|
||||
|
||||
uses
|
||||
Interfaces,
|
||||
Forms, lclversion,
|
||||
datamrg0 in 'datamrg0.pas' {Form1};
|
||||
|
||||
{$R *.res}
|
||||
|
||||
begin
|
||||
{$IFDEF LCL_FULLVERSION >= 1080000}
|
||||
Application.Scaled := True;
|
||||
{$ENDIF}
|
||||
Application.Initialize;
|
||||
Application.CreateForm(TForm1, Form1);
|
||||
Application.Run;
|
||||
end.
|
||||
331
components/systools/examples/data_merge/datamrg0.lfm
Normal file
331
components/systools/examples/data_merge/datamrg0.lfm
Normal file
@@ -0,0 +1,331 @@
|
||||
object Form1: TForm1
|
||||
Left = 241
|
||||
Height = 601
|
||||
Top = 131
|
||||
Width = 854
|
||||
Caption = 'Data Merge Example'
|
||||
ClientHeight = 601
|
||||
ClientWidth = 854
|
||||
Color = clBtnFace
|
||||
Font.Color = clWindowText
|
||||
OnCreate = FormCreate
|
||||
OnDestroy = FormDestroy
|
||||
LCLVersion = '1.9.0.0'
|
||||
object Splitter1: TSplitter
|
||||
Cursor = crVSplit
|
||||
Left = 0
|
||||
Height = 3
|
||||
Top = 408
|
||||
Width = 854
|
||||
Align = alBottom
|
||||
ResizeAnchor = akBottom
|
||||
end
|
||||
object Splitter2: TSplitter
|
||||
Left = 185
|
||||
Height = 408
|
||||
Top = 0
|
||||
Width = 5
|
||||
end
|
||||
object Panel1: TPanel
|
||||
AnchorSideTop.Side = asrCenter
|
||||
Left = 0
|
||||
Height = 38
|
||||
Top = 563
|
||||
Width = 854
|
||||
Align = alBottom
|
||||
ClientHeight = 38
|
||||
ClientWidth = 854
|
||||
TabOrder = 0
|
||||
object Button1: TButton
|
||||
AnchorSideLeft.Control = Panel1
|
||||
AnchorSideTop.Control = Panel1
|
||||
AnchorSideTop.Side = asrCenter
|
||||
Left = 5
|
||||
Height = 25
|
||||
Top = 7
|
||||
Width = 108
|
||||
AutoSize = True
|
||||
BorderSpacing.Left = 4
|
||||
Caption = 'Open Template'
|
||||
OnClick = Button1Click
|
||||
TabOrder = 0
|
||||
end
|
||||
object Button2: TButton
|
||||
AnchorSideLeft.Control = Button5
|
||||
AnchorSideLeft.Side = asrBottom
|
||||
AnchorSideTop.Control = Panel1
|
||||
AnchorSideTop.Side = asrCenter
|
||||
Left = 224
|
||||
Height = 25
|
||||
Top = 7
|
||||
Width = 98
|
||||
AutoSize = True
|
||||
BorderSpacing.Left = 4
|
||||
Caption = 'Load Data Set'
|
||||
OnClick = Button2Click
|
||||
TabOrder = 2
|
||||
end
|
||||
object Button3: TButton
|
||||
AnchorSideLeft.Control = Button6
|
||||
AnchorSideLeft.Side = asrBottom
|
||||
AnchorSideTop.Control = Panel1
|
||||
AnchorSideTop.Side = asrCenter
|
||||
Left = 431
|
||||
Height = 25
|
||||
Top = 7
|
||||
Width = 60
|
||||
AutoSize = True
|
||||
BorderSpacing.Left = 4
|
||||
Caption = 'Merge'
|
||||
OnClick = Button3Click
|
||||
TabOrder = 4
|
||||
end
|
||||
object Panel5: TPanel
|
||||
Left = 696
|
||||
Height = 36
|
||||
Top = 1
|
||||
Width = 157
|
||||
Align = alRight
|
||||
ClientHeight = 36
|
||||
ClientWidth = 157
|
||||
TabOrder = 6
|
||||
object SpeedButton1: TSpeedButton
|
||||
AnchorSideTop.Control = Panel5
|
||||
AnchorSideTop.Side = asrCenter
|
||||
Left = 13
|
||||
Height = 22
|
||||
Top = 7
|
||||
Width = 23
|
||||
Glyph.Data = {
|
||||
76010000424D7601000000000000760000002800000020000000100000000100
|
||||
0400000000000001000000000000000000001000000010000000000000000000
|
||||
800000800000008080008000000080008000808000007F7F7F00BFBFBF000000
|
||||
FF0000FF000000FFFF00FF000000FF00FF00FFFF0000FFFFFF00333333333333
|
||||
33333333333333333333EEEEEEEEEEEEEEE333FFFFFFFFFFFFF3E00000000000
|
||||
00E337777777777777F3E0F77777777770E337F33333333337F3E0F333333333
|
||||
70E337F33333333337F3E0F33333333370E337F3333F3FF337F3E0F333030033
|
||||
70E337F3337F77F337F3E0F33003003370E337F3377F77F337F3E0F300030033
|
||||
70E337F3777F77F337F3E0F33003003370E337F3377F77F337F3E0F333030033
|
||||
70E337F33373773337F3E0F33333333370E337F33333333337F3E0F333333333
|
||||
70E337F33333333337F3E0FFFFFFFFFFF0E337FFFFFFFFFFF7F3E00000000000
|
||||
00E33777777777777733EEEEEEEEEEEEEEE33333333333333333
|
||||
}
|
||||
NumGlyphs = 2
|
||||
OnClick = NavClick
|
||||
end
|
||||
object SpeedButton2: TSpeedButton
|
||||
AnchorSideTop.Control = Panel5
|
||||
AnchorSideTop.Side = asrCenter
|
||||
Left = 49
|
||||
Height = 22
|
||||
Top = 7
|
||||
Width = 23
|
||||
Glyph.Data = {
|
||||
76010000424D7601000000000000760000002800000020000000100000000100
|
||||
0400000000000001000000000000000000001000000010000000000000000000
|
||||
8000008000000080800080000000800080008080000080808000C0C0C0000000
|
||||
FF0000FF000000FFFF00FF000000FF00FF00FFFF0000FFFFFF00333333333333
|
||||
33333333333333333333EEEEEEEEEEEEEEE333FFFFFFFFFFFFF3E00000000000
|
||||
00E337777777777777F3E0F77777777770E337F33333333337F3E0F333333333
|
||||
70E337F33333F33337F3E0F33333033370E337F3333FF73337F3E0F333300333
|
||||
70E337F333FF773337F3E0F33300033370E337F33FF7773337F3E0F330000333
|
||||
70E337F33377773337F3E0F33300033370E337F33337773337F3E0F333300333
|
||||
70E337F33333773337F3E0F33333033370E337F33333373337F3E0F333333333
|
||||
70E337F33333333337F3E0FFFFFFFFFFF0E337FFFFFFFFFFF7F3E00000000000
|
||||
00E33777777777777733EEEEEEEEEEEEEEE33333333333333333
|
||||
}
|
||||
NumGlyphs = 2
|
||||
OnClick = NavClick
|
||||
end
|
||||
object SpeedButton3: TSpeedButton
|
||||
AnchorSideTop.Control = Panel5
|
||||
AnchorSideTop.Side = asrCenter
|
||||
Left = 85
|
||||
Height = 22
|
||||
Top = 7
|
||||
Width = 23
|
||||
Glyph.Data = {
|
||||
76010000424D7601000000000000760000002800000020000000100000000100
|
||||
0400000000000001000000000000000000001000000010000000000000000000
|
||||
800000800000008080008000000080008000808000007F7F7F00BFBFBF000000
|
||||
FF0000FF000000FFFF00FF000000FF00FF00FFFF0000FFFFFF00333333333333
|
||||
33333333333333333333EEEEEEEEEEEEEEE333FFFFFFFFFFFFF3E00000000000
|
||||
00E337777777777777F3E0F77777777770E337F33333333337F3E0F333333333
|
||||
70E337F3333F333337F3E0F33303333370E337F3337FF33337F3E0F333003333
|
||||
70E337F33377FF3337F3E0F33300033370E337F333777FF337F3E0F333000033
|
||||
70E337F33377773337F3E0F33300033370E337F33377733337F3E0F333003333
|
||||
70E337F33377333337F3E0F33303333370E337F33373333337F3E0F333333333
|
||||
70E337F33333333337F3E0FFFFFFFFFFF0E337FFFFFFFFFFF7F3E00000000000
|
||||
00E33777777777777733EEEEEEEEEEEEEEE33333333333333333
|
||||
}
|
||||
NumGlyphs = 2
|
||||
OnClick = NavClick
|
||||
end
|
||||
object SpeedButton4: TSpeedButton
|
||||
AnchorSideTop.Control = Panel5
|
||||
AnchorSideTop.Side = asrCenter
|
||||
Left = 121
|
||||
Height = 22
|
||||
Top = 7
|
||||
Width = 23
|
||||
Glyph.Data = {
|
||||
76010000424D7601000000000000760000002800000020000000100000000100
|
||||
0400000000000001000000000000000000001000000010000000000000000000
|
||||
800000800000008080008000000080008000808000007F7F7F00BFBFBF000000
|
||||
FF0000FF000000FFFF00FF000000FF00FF00FFFF0000FFFFFF00333333333333
|
||||
33333333333333333333EEEEEEEEEEEEEEE333FFFFFFFFFFFFF3E00000000000
|
||||
00E337777777777777F3E0F77777777770E337F33333333337F3E0F333333333
|
||||
70E337F33333333337F3E0F33333333370E337F333FF3F3337F3E0F330030333
|
||||
70E337F3377F7FF337F3E0F33003003370E337F3377F77FF37F3E0F330030003
|
||||
70E337F3377F777337F3E0F33003003370E337F3377F773337F3E0F330030333
|
||||
70E337F33773733337F3E0F33333333370E337F33333333337F3E0F333333333
|
||||
70E337F33333333337F3E0FFFFFFFFFFF0E337FFFFFFFFFFF7F3E00000000000
|
||||
00E33777777777777733EEEEEEEEEEEEEEE33333333333333333
|
||||
}
|
||||
NumGlyphs = 2
|
||||
OnClick = NavClick
|
||||
end
|
||||
end
|
||||
object Button4: TButton
|
||||
AnchorSideLeft.Control = Button3
|
||||
AnchorSideLeft.Side = asrBottom
|
||||
AnchorSideTop.Control = Panel1
|
||||
AnchorSideTop.Side = asrCenter
|
||||
Left = 495
|
||||
Height = 25
|
||||
Top = 7
|
||||
Width = 87
|
||||
AutoSize = True
|
||||
BorderSpacing.Left = 4
|
||||
Caption = 'Save Merge'
|
||||
OnClick = Button4Click
|
||||
TabOrder = 5
|
||||
end
|
||||
object Button5: TButton
|
||||
AnchorSideLeft.Control = Button1
|
||||
AnchorSideLeft.Side = asrBottom
|
||||
AnchorSideTop.Control = Panel1
|
||||
AnchorSideTop.Side = asrCenter
|
||||
Left = 117
|
||||
Height = 25
|
||||
Top = 7
|
||||
Width = 103
|
||||
AutoSize = True
|
||||
BorderSpacing.Left = 4
|
||||
Caption = 'Save Template'
|
||||
OnClick = Button5Click
|
||||
TabOrder = 1
|
||||
end
|
||||
object Button6: TButton
|
||||
AnchorSideLeft.Control = Button2
|
||||
AnchorSideLeft.Side = asrBottom
|
||||
AnchorSideTop.Control = Panel1
|
||||
AnchorSideTop.Side = asrCenter
|
||||
Left = 326
|
||||
Height = 25
|
||||
Top = 7
|
||||
Width = 101
|
||||
AutoSize = True
|
||||
BorderSpacing.Left = 4
|
||||
Caption = 'Close Data Set'
|
||||
OnClick = Button6Click
|
||||
TabOrder = 3
|
||||
end
|
||||
end
|
||||
object Panel2: TPanel
|
||||
Left = 0
|
||||
Height = 152
|
||||
Top = 411
|
||||
Width = 854
|
||||
Align = alBottom
|
||||
ClientHeight = 152
|
||||
ClientWidth = 854
|
||||
TabOrder = 3
|
||||
object Memo1: TMemo
|
||||
Left = 1
|
||||
Height = 150
|
||||
Top = 1
|
||||
Width = 852
|
||||
Align = alClient
|
||||
OnDblClick = ClearMemo
|
||||
ScrollBars = ssBoth
|
||||
TabOrder = 0
|
||||
WordWrap = False
|
||||
end
|
||||
end
|
||||
object Panel3: TPanel
|
||||
Left = 0
|
||||
Height = 408
|
||||
Top = 0
|
||||
Width = 185
|
||||
Align = alLeft
|
||||
ClientHeight = 408
|
||||
ClientWidth = 185
|
||||
TabOrder = 1
|
||||
object Memo2: TMemo
|
||||
Left = 1
|
||||
Height = 406
|
||||
Top = 1
|
||||
Width = 183
|
||||
Align = alClient
|
||||
OnDblClick = ClearMemo
|
||||
ScrollBars = ssBoth
|
||||
TabOrder = 0
|
||||
WordWrap = False
|
||||
end
|
||||
end
|
||||
object Panel4: TPanel
|
||||
Left = 190
|
||||
Height = 408
|
||||
Top = 0
|
||||
Width = 664
|
||||
Align = alClient
|
||||
ClientHeight = 408
|
||||
ClientWidth = 664
|
||||
TabOrder = 2
|
||||
object Memo3: TMemo
|
||||
Left = 1
|
||||
Height = 406
|
||||
Top = 1
|
||||
Width = 662
|
||||
Align = alClient
|
||||
OnDblClick = ClearMemo
|
||||
ScrollBars = ssBoth
|
||||
TabOrder = 0
|
||||
WordWrap = False
|
||||
end
|
||||
end
|
||||
object OpenDialog1: TOpenDialog
|
||||
DefaultExt = '.txt'
|
||||
FileName = '*.txt'
|
||||
Filter = 'Text Files (*.txt)|*.txt|dlg'
|
||||
left = 504
|
||||
top = 64
|
||||
end
|
||||
object OpenDialog2: TOpenDialog
|
||||
Title = 'Open Schema File'
|
||||
DefaultExt = '.sch'
|
||||
FileName = '*.sch'
|
||||
Filter = 'Schema Files (*.sch)|*.sch|All Files (*.*)|*.*'
|
||||
InitialDir = 'c:\cache\Data'
|
||||
left = 504
|
||||
top = 120
|
||||
end
|
||||
object OpenDialog3: TOpenDialog
|
||||
Title = 'Open CSV File'
|
||||
DefaultExt = '.csv'
|
||||
FileName = '*.csv'
|
||||
Filter = 'CSV Files (*.csv)|*.csv|All Files (*.*)|*.*'
|
||||
InitialDir = 'c:\cache\data'
|
||||
left = 504
|
||||
top = 176
|
||||
end
|
||||
object SaveDialog1: TSaveDialog
|
||||
left = 504
|
||||
top = 232
|
||||
end
|
||||
object SaveDialog2: TSaveDialog
|
||||
left = 504
|
||||
top = 288
|
||||
end
|
||||
end
|
||||
260
components/systools/examples/data_merge/datamrg0.pas
Normal file
260
components/systools/examples/data_merge/datamrg0.pas
Normal file
@@ -0,0 +1,260 @@
|
||||
(* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is TurboPower SysTools
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* TurboPower Software
|
||||
*
|
||||
* Portions created by the Initial Developer are Copyright (C) 1996-2002
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** *)
|
||||
|
||||
{$IFDEF FPC}
|
||||
{$mode DELPHI}
|
||||
{$ENDIF}
|
||||
|
||||
unit datamrg0;
|
||||
|
||||
interface
|
||||
|
||||
uses
|
||||
{$IFNDEF FPC}
|
||||
Windows, Messages,
|
||||
{$ENDIF}
|
||||
SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
|
||||
ExtCtrls, StdCtrls, Buttons,
|
||||
|
||||
StTxtDat, StMerge;
|
||||
|
||||
type
|
||||
TForm1 = class(TForm)
|
||||
Panel1: TPanel;
|
||||
Panel2: TPanel;
|
||||
Splitter1: TSplitter;
|
||||
Panel3: TPanel;
|
||||
Splitter2: TSplitter;
|
||||
Panel4: TPanel;
|
||||
Memo1: TMemo;
|
||||
Memo2: TMemo;
|
||||
Memo3: TMemo;
|
||||
Button1: TButton;
|
||||
OpenDialog1: TOpenDialog;
|
||||
OpenDialog2: TOpenDialog;
|
||||
OpenDialog3: TOpenDialog;
|
||||
Button2: TButton;
|
||||
Button3: TButton;
|
||||
Panel5: TPanel;
|
||||
SpeedButton1: TSpeedButton;
|
||||
SpeedButton2: TSpeedButton;
|
||||
SpeedButton3: TSpeedButton;
|
||||
SpeedButton4: TSpeedButton;
|
||||
Button4: TButton;
|
||||
SaveDialog1: TSaveDialog;
|
||||
Button5: TButton;
|
||||
SaveDialog2: TSaveDialog;
|
||||
Button6: TButton;
|
||||
procedure Button2Click(Sender: TObject);
|
||||
procedure FormDestroy(Sender: TObject);
|
||||
procedure Button1Click(Sender: TObject);
|
||||
procedure NavClick(Sender: TObject);
|
||||
procedure Button4Click(Sender: TObject);
|
||||
procedure FormCreate(Sender: TObject);
|
||||
procedure Button3Click(Sender: TObject);
|
||||
procedure Button5Click(Sender: TObject);
|
||||
procedure ClearMemo(Sender: TObject);
|
||||
procedure Button6Click(Sender: TObject);
|
||||
private
|
||||
procedure UpdateButtons;
|
||||
procedure UpdateTagDisplay;
|
||||
function NextFile: string;
|
||||
procedure DoUnknownTag(Sender: TObject; Tag: AnsiString;
|
||||
var Value: AnsiString; var Discard: Boolean);
|
||||
procedure DisableButtons;
|
||||
{ Private declarations }
|
||||
public
|
||||
TemplateName : string;
|
||||
MergeNo : Integer;
|
||||
Schema : TStTextDataSchema;
|
||||
DataSet : TStTextDataRecordSet;
|
||||
Merger : TStTextMerge;
|
||||
{ Public declarations }
|
||||
end;
|
||||
|
||||
var
|
||||
Form1: TForm1;
|
||||
|
||||
implementation
|
||||
|
||||
{$IFDEF FPC}
|
||||
{$R *.lfm}
|
||||
{$ELSE}
|
||||
{$R *.dfm}
|
||||
{$ENDIF}
|
||||
|
||||
procedure TForm1.Button2Click(Sender: TObject);
|
||||
begin
|
||||
if OpenDialog2.Execute and OpenDialog3.Execute then begin
|
||||
Schema.Free;
|
||||
Schema := TStTextDataSchema.Create;
|
||||
Schema.LoadFromFile(OpenDialog2.FileName);
|
||||
|
||||
DataSet.Free;
|
||||
DataSet := TStTextDataRecordSet.Create;
|
||||
DataSet.Schema := Schema;
|
||||
DataSet.LoadFromFile(OpenDialog3.FileName);
|
||||
DataSet.First;
|
||||
|
||||
UpdateButtons;
|
||||
UpdateTagDisplay;
|
||||
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TForm1.FormDestroy(Sender: TObject);
|
||||
begin
|
||||
Schema.Free;
|
||||
DataSet.Free;
|
||||
Merger.Free;
|
||||
end;
|
||||
|
||||
procedure TForm1.Button1Click(Sender: TObject);
|
||||
begin
|
||||
if OpenDialog1.Execute then begin
|
||||
TemplateName := OpenDialog1.FileName;
|
||||
MergeNo := 1;
|
||||
Merger.LoadTemplateFromFile(TemplateName);
|
||||
Memo3.Lines.Assign(Merger.Template);
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TForm1.UpdateTagDisplay;
|
||||
begin
|
||||
Memo2.Lines.Assign(DataSet.CurrentRecord.FieldList);
|
||||
end;
|
||||
|
||||
procedure TForm1.DisableButtons;
|
||||
begin
|
||||
SpeedButton1.Enabled := False;
|
||||
SpeedButton2.Enabled := False;
|
||||
SpeedButton3.Enabled := False;
|
||||
SpeedButton4.Enabled := False;
|
||||
end;
|
||||
|
||||
procedure TForm1.UpdateButtons;
|
||||
begin
|
||||
if DataSet.Active then begin
|
||||
|
||||
SpeedButton1.Enabled := True;
|
||||
SpeedButton2.Enabled := True;
|
||||
SpeedButton3.Enabled := True;
|
||||
SpeedButton4.Enabled := True;
|
||||
|
||||
if DataSet.BOF then begin
|
||||
SpeedButton1.Enabled := False;
|
||||
SpeedButton2.Enabled := False;
|
||||
end;
|
||||
|
||||
if DataSet.EOF then begin
|
||||
SpeedButton3.Enabled := False;
|
||||
SpeedButton4.Enabled := False;
|
||||
end;
|
||||
|
||||
end else
|
||||
DisableButtons;
|
||||
end;
|
||||
|
||||
procedure TForm1.NavClick(Sender: TObject);
|
||||
begin
|
||||
if Sender = SpeedButton1 then DataSet.First;
|
||||
if Sender = SpeedButton2 then DataSet.Prior;
|
||||
if Sender = SpeedButton3 then DataSet.Next;
|
||||
if Sender = SpeedButton4 then DataSet.Last;
|
||||
|
||||
UpdateButtons;
|
||||
UpdateTagDisplay;
|
||||
end;
|
||||
|
||||
function TForm1.NextFile : string;
|
||||
begin
|
||||
Result := ChangeFileExt(ExtractFileName(TemplateName),
|
||||
Format('.M%.2d', [MergeNo]));
|
||||
Inc(MergeNo);
|
||||
end;
|
||||
|
||||
procedure TForm1.Button4Click(Sender: TObject);
|
||||
begin
|
||||
SaveDialog1.FileName := NextFile;
|
||||
if SaveDialog1.Execute then begin
|
||||
Memo3.Lines.SaveToFile(SaveDialog1.FileName);
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TForm1.DoUnknownTag(Sender : TObject; Tag : AnsiString;
|
||||
var Value : AnsiString; var Discard : Boolean);
|
||||
begin
|
||||
if Tag = 'TIME' then
|
||||
Value := FormatDateTime('hh:mm:ss', Now)
|
||||
else
|
||||
Value := InputBox('Unknown Tag', 'Value for ' + Tag, '');
|
||||
end;
|
||||
|
||||
procedure TForm1.FormCreate(Sender: TObject);
|
||||
begin
|
||||
Merger := TStTextMerge.Create;
|
||||
Merger.DefaultTags.Add('FIRST_NAME=Sir or Madam');
|
||||
Merger.DefaultTags.Add('CITY=ANYTOWN');
|
||||
Merger.DefaultTags.Add('COLOR=BLUE');
|
||||
Merger.OnGotUnknownTag := DoUnknownTag;
|
||||
|
||||
DisableButtons;
|
||||
end;
|
||||
|
||||
procedure TForm1.Button3Click(Sender: TObject);
|
||||
begin
|
||||
Merger.MergeTags.Assign(Memo2.Lines);
|
||||
Merger.Merge;
|
||||
Memo1.Lines.Assign(Merger.MergedText);
|
||||
end;
|
||||
|
||||
procedure TForm1.Button5Click(Sender: TObject);
|
||||
begin
|
||||
SaveDialog2.FileName := TemplateName;
|
||||
if SaveDialog2.Execute then begin
|
||||
TemplateName := SaveDialog2.FileName;
|
||||
Memo3.Lines.SaveToFile(TemplateName);
|
||||
Merger.Template.Assign(Memo3.Lines);
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TForm1.ClearMemo(Sender: TObject);
|
||||
begin
|
||||
(Sender as TMemo).Lines.Clear;
|
||||
end;
|
||||
|
||||
|
||||
procedure TForm1.Button6Click(Sender: TObject);
|
||||
begin
|
||||
if Assigned(DataSet) and DataSet.Active then begin
|
||||
DataSet.Active := False;
|
||||
DataSet.Free;
|
||||
DataSet := nil;
|
||||
Memo2.Lines.Clear;
|
||||
DisableButtons;
|
||||
end;
|
||||
end;
|
||||
|
||||
end.
|
||||
Reference in New Issue
Block a user