Skip to content

Commit 21fa7bf

Browse files
ADD: Cleanup for better informations
1 parent 1a61b67 commit 21fa7bf

File tree

5 files changed

+97
-36
lines changed

5 files changed

+97
-36
lines changed

data_control/LZW/Readme.md

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# Lempel-Ziv-Welch (LZW)
2+
3+
This Demo shows how the ulzw.pas can be used.
4+
5+
![](preview.png)
6+
7+
8+
Features:
9+
- load and compress a single file with the LZW algorithm (including some statistics)
10+
- load and uncompress a compressed file

data_control/LZW/Unit1.lfm

+21-14
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
object Form1: TForm1
2-
Left = 237
3-
Height = 155
4-
Top = 122
5-
Width = 330
2+
Left = 347
3+
Height = 209
4+
Top = 107
5+
Width = 335
66
ActiveControl = Button1
77
BorderIcons = [biSystemMenu, biMinimize]
88
BorderStyle = bsSingle
99
Caption = 'Form1'
10-
ClientHeight = 155
11-
ClientWidth = 330
10+
ClientHeight = 209
11+
ClientWidth = 335
1212
Font.Height = -11
1313
Font.Name = 'MS Sans Serif'
1414
OnCreate = FormCreate
@@ -29,7 +29,7 @@ object Form1: TForm1
2929
Height = 25
3030
Top = 4
3131
Width = 137
32-
Caption = '&Open File'
32+
Caption = '&Open file'
3333
OnClick = Button1Click
3434
TabOrder = 0
3535
end
@@ -48,15 +48,15 @@ object Form1: TForm1
4848
Height = 25
4949
Top = 4
5050
Width = 137
51-
Caption = 'O&pen File'
51+
Caption = 'O&pen file'
5252
OnClick = Button3Click
5353
TabOrder = 0
5454
end
5555
end
5656
object Button5: TButton
5757
Left = 16
5858
Height = 25
59-
Top = 120
59+
Top = 168
6060
Width = 297
6161
Caption = '&Close'
6262
OnClick = Button5Click
@@ -65,21 +65,28 @@ object Form1: TForm1
6565
object Button6: TButton
6666
Left = 16
6767
Height = 25
68-
Top = 80
68+
Top = 128
6969
Width = 297
7070
Caption = '&Help / Support'
7171
OnClick = Button6Click
7272
TabOrder = 3
7373
end
74+
object Label1: TLabel
75+
Left = 8
76+
Height = 14
77+
Top = 72
78+
Width = 37
79+
Caption = 'Label1'
80+
end
7481
object OpenDialog1: TOpenDialog
75-
Left = 24
76-
Top = 32
82+
Left = 32
83+
Top = 40
7784
end
7885
object SaveDialog1: TSaveDialog
7986
DefaultExt = '.LZW'
8087
Filter = 'LZW-File|*.LZW|All|*.*'
81-
Left = 120
82-
Top = 32
88+
Left = 96
89+
Top = 40
8390
end
8491
object OpenDialog2: TOpenDialog
8592
DefaultExt = '.LZW'

data_control/LZW/Unit1.pas

+28-14
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
(******************************************************************************)
22
(* Lempel-Ziv-Welch Demo 28.03.2009 *)
33
(* *)
4-
(* Version : 0.01 *)
4+
(* Version : 0.03 *)
55
(* *)
66
(* Author : Uwe Schächterle (Corpsman) *)
77
(* *)
@@ -23,6 +23,8 @@
2323
(* Known Issues: none *)
2424
(* *)
2525
(* History : 0.01 - Initial version *)
26+
(* 0.02 - Rework code internals, and Update help *)
27+
(* 0.03 - replace messagebox by label *)
2628
(* *)
2729
(******************************************************************************)
2830
Unit Unit1;
@@ -36,13 +38,17 @@
3638
StdCtrls, uLZW, LCLIntf, LCLType;
3739

3840
Type
41+
42+
{ TForm1 }
43+
3944
TForm1 = Class(TForm)
4045
GroupBox1: TGroupBox;
4146
Button1: TButton;
4247
GroupBox2: TGroupBox;
4348
Button3: TButton;
4449
Button5: TButton;
4550
Button6: TButton;
51+
Label1: TLabel;
4652
OpenDialog1: TOpenDialog;
4753
SaveDialog1: TSaveDialog;
4854
OpenDialog2: TOpenDialog;
@@ -102,15 +108,12 @@
102108

103109
Procedure TForm1.FormCreate(Sender: TObject);
104110
Begin
105-
(*
106-
* Historie: 0.01 = Initialversion
107-
* 0.02 = Rework code internals, and Update help
108-
*)
109-
caption := 'LZW ver. 0.02 by Corpsman';
111+
caption := 'LZW ver. 0.03 by Corpsman';
110112
lzw := TLZW.create;
111113
OpenDialog1.initialdir := ExtractFilePath(paramstr(0));
112114
saveDialog1.initialdir := ExtractFilePath(paramstr(0));
113115
OpenDialog2.initialdir := ExtractFilePath(paramstr(0));
116+
label1.caption := 'Click "Open file"';
114117
End;
115118

116119
Procedure TForm1.FormDestroy(Sender: TObject);
@@ -128,7 +131,7 @@
128131
End;
129132

130133
Procedure TForm1.Button1Click(Sender: TObject);
131-
{.$DEFINE EXACKTINFO}
134+
{$DEFINE EXACKTINFO}
132135
Var
133136
{$IFDEF EXACKTINFO}
134137
SizeBefore, SizeAfter,
@@ -163,16 +166,21 @@
163166
f2.CopyFrom(m2, m2.size);
164167
m2.free;
165168
f2.free;
166-
showmessage(
167-
'Ready ' + LineEnding
168-
+ 'Time :' + FloattostrF((d2 - d) / 1000, FFFixed, 7, 3)
169+
label1.caption :=
170+
'Time :' + FloattostrF((d2 - d) / 1000, FFFixed, 7, 3)
169171
{$IFDEF EXACKTINFO}
170-
+ LineEnding + 'Compression Rate :' + FloattostrF((SizeBefore / SizeAfter) * 100, FFFixed, 7, 2) + '%' + LineEnding +
171-
'M/sec :' + floattostrf(SizeBefore / (d2 - d), fffixed, 7, 3)
172+
+ LineEnding + 'Compression Rate :' + FloattostrF((SizeBefore / SizeAfter) * 100, FFFixed, 7, 2) + '%' + LineEnding +
173+
'Byte/sec :' + floattostrf(SizeBefore / (d2 - d), fffixed, 7, 3)
172174
{$ENDIF EXACKTINFO}
173-
);
175+
;
174176
button1.enabled := True;
177+
End
178+
Else Begin
179+
label1.caption := '';
175180
End;
181+
End
182+
Else Begin
183+
label1.caption := '';
176184
End;
177185
End;
178186

@@ -202,9 +210,15 @@
202210
f2 := TFileStream.create(IncludeTrailingBackslash(Path) + s, fmcreate Or fmopenwrite);
203211
f2.CopyFrom(m2, m2.size);
204212
f2.free;
205-
showmessage('Ready [ Time :' + FloattostrF((d2 - d) / 1000, FFFixed, 7, 3) + ' ].');
213+
label1.caption := 'Ready [ Time :' + FloattostrF((d2 - d) / 1000, FFFixed, 7, 3) + ' ].';
206214
button3.enabled := True;
215+
End
216+
Else Begin
217+
label1.caption := '';
207218
End;
219+
End
220+
Else Begin
221+
label1.caption := '';
208222
End;
209223
End;
210224

data_control/LZW/lzw.lpi

+38-8
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,7 @@
5353
<HasResources Value="True"/>
5454
<ResourceBaseClass Value="Form"/>
5555
<IsVisibleTab Value="True"/>
56-
<TopLine Value="76"/>
57-
<CursorPos X="73" Y="104"/>
56+
<CursorPos X="22" Y="4"/>
5857
<UsageCount Value="26"/>
5958
<Loaded Value="True"/>
6059
<LoadedDesigner Value="True"/>
@@ -93,7 +92,7 @@
9392
<UsageCount Value="10"/>
9493
</Unit6>
9594
</Units>
96-
<JumpHistory Count="10" HistoryIndex="9">
95+
<JumpHistory Count="18" HistoryIndex="17">
9796
<Position1>
9897
<Filename Value="Unit1.pas"/>
9998
<Caret Line="60" Column="16"/>
@@ -116,24 +115,55 @@
116115
</Position5>
117116
<Position6>
118117
<Filename Value="Unit1.pas"/>
119-
<Caret Line="2" Column="20" TopLine="4"/>
118+
<Caret Line="6" Column="38" TopLine="4"/>
120119
</Position6>
121120
<Position7>
122121
<Filename Value="Unit1.pas"/>
123-
<Caret Line="6" Column="38" TopLine="4"/>
122+
<Caret Line="117" Column="39" TopLine="76"/>
124123
</Position7>
125124
<Position8>
126125
<Filename Value="Unit1.pas"/>
127-
<Caret Line="117" Column="39" TopLine="76"/>
126+
<Caret Line="125" Column="37" TopLine="76"/>
128127
</Position8>
129128
<Position9>
130129
<Filename Value="Unit1.pas"/>
131-
<Caret Line="125" Column="37" TopLine="76"/>
130+
<Caret Line="2" Column="9"/>
132131
</Position9>
133132
<Position10>
134133
<Filename Value="Unit1.pas"/>
135-
<Caret Line="2" Column="9"/>
134+
<Caret Line="104" Column="73" TopLine="76"/>
136135
</Position10>
136+
<Position11>
137+
<Filename Value="Unit1.pas"/>
138+
<Caret Line="140" Column="3" TopLine="130"/>
139+
</Position11>
140+
<Position12>
141+
<Filename Value="Unit1.pas"/>
142+
<Caret Line="183" Column="20" TopLine="134"/>
143+
</Position12>
144+
<Position13>
145+
<Filename Value="Unit1.pas"/>
146+
<Caret Line="174" Column="46" TopLine="150"/>
147+
</Position13>
148+
<Position14>
149+
<Filename Value="Unit1.pas"/>
150+
<Caret Line="118" Column="41" TopLine="107"/>
151+
</Position14>
152+
<Position15>
153+
<Filename Value="Unit1.pas"/>
154+
<Caret Line="145" Column="3" TopLine="135"/>
155+
</Position15>
156+
<Position16>
157+
<Filename Value="Unit1.pas"/>
158+
<Caret Line="112" Column="20" TopLine="107"/>
159+
</Position16>
160+
<Position17>
161+
<Filename Value="Unit1.pas"/>
162+
</Position17>
163+
<Position18>
164+
<Filename Value="Unit1.pas"/>
165+
<Caret Line="109" TopLine="107"/>
166+
</Position18>
137167
</JumpHistory>
138168
</ProjectOptions>
139169
<CompilerOptions>

data_control/LZW/preview.png

14.8 KB
Loading

0 commit comments

Comments
 (0)