-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathUnit6.pas
274 lines (213 loc) · 6.58 KB
/
Unit6.pas
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
unit Unit6;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls, Buttons, ExtCtrls, TileImage;
type
TFormhledani = class(TForm)
TileImage1: TTileImage;
Edit1: TEdit;
BitBtn1: TBitBtn;
BitBtn2: TBitBtn;
Label1: TLabel;
Label2: TLabel;
BitBtn3: TBitBtn;
procedure Edit1KeyPress(Sender: TObject; var Key: Char);
procedure BitBtn1Click(Sender: TObject);
procedure Edit1Change(Sender: TObject);
procedure BitBtn3Click(Sender: TObject);
procedure Edit1Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
procedure Nevyskytuje;
end;
var
Formhledani: TFormhledani;
// fulltext : textfile;
jo : boolean;
hledat : integer ;
implementation
uses Unit1;
{$R *.DFM}
procedure TFormhledani.Edit1KeyPress(Sender: TObject; var Key: Char);
//Filtrace kláves v edit1
var rid : integer;
begin
if length(edit1.text)=0 then begin
for rid := 0 to 47 do begin
if key = Chr(rid) then key := Chr(10);
end;
for rid := 60 to 64 do begin
if key = Chr(rid) then key := Chr(10);
end;
for rid := 91 to 96 do begin
if key = Chr(rid) then key := Chr(10);
end;
for rid := 123 to 255 do begin
if key = Chr(rid) then key := Chr(10);
end;
end;
if Key = 'a' then Key := 'A';
if Key = 'b' then Key := 'B';
if Key = 'c' then Key := 'C';
if Key = 'd' then Key := 'D';
if Key = 'e' then Key := 'E';
if Key = 'f' then Key := 'F';
if Key = 'g' then Key := 'G';
if Key = 'h' then Key := 'H';
if Key = 'i' then Key := 'I';
if Key = 'j' then Key := 'J';
if Key = 'k' then Key := 'K';
if Key = 'l' then Key := 'L';
if Key = 'm' then Key := 'M';
if Key = 'n' then Key := 'N';
if Key = 'o' then Key := 'O';
if Key = 'p' then Key := 'P';
if Key = 'q' then Key := 'Q';
if Key = 'r' then Key := 'R';
if Key = 's' then Key := 'S';
if Key = 't' then Key := 'T';
if Key = 'u' then Key := 'U';
if Key = 'v' then Key := 'V';
if Key = 'w' then Key := 'W';
if Key = 'x' then Key := 'X';
if Key = 'y' then Key := 'Y';
if Key = 'z' then Key := 'Z';
if Key = 'ì' then Key := 'Ì';
if Key = 'š' then Key := 'Š';
if Key = 'è' then Key := 'È';
if Key = 'ø' then Key := 'Ø';
if Key = 'ž' then Key := 'Ž';
if Key = 'ý' then Key := 'Ý';
if Key = 'á' then Key := 'Á';
if Key = 'í' then Key := 'Í';
if Key = 'é' then Key := 'É';
if Key = 'ù' then Key := 'Ù';
if Key = 'ú' then Key := 'Ú';
if Key = 'ó' then Key := 'Ó';
if Key = 'ï' then Key := 'Ï';
if Key = 'ò' then Key := 'Ò';
if Key = '' then Key := '';
end;
//Najít další položku
procedure TFormhledani.BitBtn1Click(Sender: TObject);
var retez : string;
inpozice : integer;
pozice : byte;
begin
if (length(edit1.text) > 0) and (AktStr.count > 0) then begin
unit1.filtr := '';
jo := false;
repeat
if hledat < AktStr.count-1 then begin
hledat := hledat + 1;
end else begin
Nevyskytuje;
hledat := 0;
end;
retez := AktStr.names[hledat];
pozice := 0;
repeat
Inc(pozice);
if length(retez) > 0 then begin
if AnsiUpperCase(retez[pozice]) = AnsiUpperCase(edit1.text[1]) then begin
jo := true;
if length(edit1.text) > length(retez) then begin
jo := false;
end else begin
if length(edit1.Text) < length(retez) then begin
for inpozice := 2 to length(edit1.text) do begin
if AnsiUpperCase(edit1.text[inpozice]) <> AnsiUpperCase(retez[pozice+inpozice-1]) then begin
jo := false;
end;
end;
end;
if length(edit1.Text) = length(retez) then begin
if AnsiUpperCase(edit1.Text) = AnsiUpperCase(retez) then begin
jo := true;
end else begin
jo := false;
end;
end;
end;
end;
end;
until (pozice = length(retez))or jo;
until (hledat = AktStr.count-1) or jo;
end;
if (hledat = AktStr.count-1) and (jo <> true) then begin
Nevyskytuje;
hledat := -1;
end;
if jo = true then begin
label2.caption := retez;
end;
end;
procedure TFormhledani.Nevyskytuje;
begin
if jazyk = 'svk' then begin
Application.messagebox('Žiadna ïalšia položka sa v databáze nevyskytuje','Koniec súboru',mb_ok + mb_iconasterisk);
end else begin
Application.messagebox('Žádná další položka se v databázi nevyskytuje','Konec souboru',mb_ok + mb_iconasterisk);
end;
end;
procedure TFormhledani.Edit1Change(Sender: TObject);
begin
hledat := -1;
jo := false;
end;
//OK
procedure TFormhledani.BitBtn3Click(Sender: TObject);
var x : byte;
begin
if (label2.caption <> '') and (AktStr.count > 0) then begin
form1.edit1.text := '';
form1.edit1.text := form1.edit1.text + label2.caption[1];
form1.edit1change(sender);
form1.listbox2.itemindex := Ord(label2.caption[1])-64;
for x:= 0 to 9 do begin
if label2.caption[1] = inttostr(x) then begin
form1.listbox2.itemindex := 0;
end;
end;
form1.edit1.text := label2.caption;
{ if form1.listbox2.itemindex = -1 then form1.listbox2.itemindex := 0;
form1.listbox2click(sender);
form1.edit1change(sender);}
end;
form1.edit1.selectall;
Close;
end;
procedure TFormhledani.Edit1Click(Sender: TObject);
begin
edit1.selectall;
end;
procedure TFormhledani.FormCreate(Sender: TObject);
begin
bitbtn3.glyph := form1.OKBut.glyph;
if unit1.jazyk = 'svk' then begin
caption := 'FullText h¾adanie';
label1.caption := 'Zadaj h¾adanú èas názvu';
bitbtn1.glyph := form1.NAJITSVKBut.glyph;
bitbtn2.glyph := form1.ZRUSITSVKBut.glyph;
end else begin
bitbtn1.glyph := form1.NAJITBut.glyph;
bitbtn2.glyph := form1.ZRUSITBut.glyph;
end;
color := form1.color;
tileimage1.picture := form1.tileimage1.picture;
edit1.color := form1.edit1.color;
edit1.font.color := form1.edit1.font.color;
label1.color := form1.label1.color;
label1.font.color := form1.label1.font.color;
label2.color := form1.label1.color;
label2.font.color := form1.label1.font.color;
if form1.AlphaBlend = true then begin
AlphaBlend := true;
AlphaBlendValue := Form1.AlphaBlendValue;
end;
end;
end.