OSDN Git Service

半角空白があったときにNGワードの区切りがおかしくなるバグを修正
[gikonavigoeson/gikonavi.git] / AbonUnit.pas
1 unit AbonUnit;
2
3 interface
4 uses
5     Windows,Messages, ShellAPI, SysUtils, Classes,StdCtrls,StrUtils;
6
7 type
8   TIndiviAbon = record
9         Res: Integer;
10     option: Integer; // 0:\93§\96¾ 1:\92Ê\8fí\82 \82Ú\81[\82ñ
11   end;
12
13   TAbon = class(TObject)
14   private
15     { Private \90é\8c¾ }
16     Froot : String;
17     Flistpath : String;
18     FNGwordpath : String;
19     Ftokens : array of array of string;
20     FAbonRes : array of TIndiviAbon;
21     FAbonString : String;
22     FCutoffNum : Integer; //\82±\82Ì\90\94\88È\8fã\98A\91±\82·\82é\93¯\82\89p\8e\9a\82ðNG\83\8f\81[\83h\82Æ\82·\82é
23     FDeleterlo : Boolean; //&rlo;\82ð\8dí\82é\82©
24     FReplaceul :Boolean ; //<ul>\83^\83O\82ð<br>\83^\83O\82É\92u\8a·\82·\82é\82©
25     FReverse : Boolean ;  //NG\83\8f\81[\83h\82Å\82Ì\82 \82Ú\81`\82ñ\82Ì\8c\8b\89Ê\82ð\94½\93]\82³\82¹\82é\82©
26     FAbonPopupRes : Boolean; //\83\8c\83X\83|\83b\83v\83A\83b\83v\82Ì\8e\9e\82É\82 \82Ú\81[\82ñ\82·\82é\82©
27     FCreateNGwordFile : Boolean; //\8ew\92è\82³\82ê\82½path\82ÉNG\83\8f\81[\83htxt\82ª\96³\82©\82Á\82½\82Æ\82«\82É\8e©\93®\93I\82É\90\90¬\82·\82é\82©
28     FNGwordFileIndex : Integer; //\8c»\8dÝ\93Ç\82Ý\8d\9e\82ñ\82Å\82éNG\83\8f\81[\83h\82ªlist\82Ì\89½\8ds\96Ú\82©
29     FNGwordname : String; //\8c»\8dÝ\93Ç\82Ý\8d\9e\82ñ\82Å\82éNG\83\8f\81[\83h\82Ì\95\\8e¦\96¼
30     FIndividualFileName : String;       //\8cÂ\95Ê\82 \82Ú\81`\82ñ\82Ì\83t\83@\83C\83\8b\96¼
31     procedure SetTokens(index: integer ; argline:String);
32     function Getlistpath() : String;
33     procedure Setlistpath(const Value : String);
34     function LoadListFile(path :String;listStringList : TStringList) : Boolean;
35     function ReadNGwordslist(line : Integer) : Boolean;
36     function LoadFromSetResNumFile(SetResNumFile : String) : Boolean;
37   public
38     { Public \90é\8c¾ }
39     constructor Create; // \83R\83\93\83X\83g\83\89\83N\83^
40     destructor Destroy; override; // \83f\83X\83g\83\89\83N\83^
41     property Deleterlo: Boolean read FDeleterlo write FDeleterlo  default false;
42     property Replaceul: Boolean read FReplaceul write FReplaceul  default false;
43     property Reverse: Boolean read FReverse write FReverse  default false;
44     property CreateNGwordFile: Boolean read FCreateNGwordFile write FCreateNGwordFile;
45     property AbonString : String read FAbonString write FAbonString;
46     property  AbonPopupRes : Boolean read FAbonPopupRes write FAbonPopupRes default false;
47     property listpath : String read Getlistpath write Setlistpath;
48     property NGwordFileIndex : Integer read FNGwordFileIndex write FNGwordFileIndex default 0;
49     property NGwordname : String read FNGwordname write FNGwordname;
50     procedure Setroot(root :String);
51     function Getroot() : String;
52
53     function Getfullpath(argpath : String) : String;
54     procedure SetNGwordpath(path :String);
55     function GetNGwordpath() : String;
56     function LoadFromNGwordFile(path :String) : Boolean;
57     function ReLoadFromNGwordFile() : Boolean;
58     procedure LoadFromStringList( bufstl : TStringList );
59     function CheckAbonPopupRes(line : String) :Boolean;
60     function FindNGwords(line : String) : Boolean; //1\83\89\83C\83\93\82¸\82Â\97p\81B
61     function Cutoff(line : String) : Boolean; //CutOff\92l\88È\8fã\8cÂ\82Ì\93¯\82\89p\90\94\82ª\95À\82ñ\82Å\82¢\82½\82çtrue
62     //\82 \82Ú\81`\82ñ\8f\88\97\9d(NG\83\8f\81[\83h\82Å\82Ì\83t\83B\83\8b\83^\83\8a\83\93\83O)
63     procedure Execute(var ThreadStrings : TStringList); overload;
64     procedure Execute(var ThreadStrings : TStringList; NGwords : TStringList); overload;
65     procedure Execute(var ThreadStrings : TStringList; NGwords : TStrings); overload;
66     //\8cÂ\95Ê\82 \82Ú\81`\82ñ\82µ\82å\82è
67     procedure IndividualAbon(var ThreadStrings : TStringList; SetResNumFile : String);
68     procedure AddIndividualAbon( ResNum : Integer ; option : Integer);
69     procedure DeleteIndividualAbon( ResNum : Integer);
70     function GetAbonResCount() : Integer;
71     function GetAbonResString(Num : Integer) : String;
72     function CheckIndividualAbonList(ResNum : Integer) : Boolean;
73     //--
74     function ExecuteFile(datfilepath : String; NGwordpath : String) : Boolean; overload;//DAT\83t\83@\83C\83\8b\82ð\92¼\82É\82¢\82\82é
75     function ExecuteFile(datfilepath : String; resnum : Integer) : Boolean; overload; //DAT\83t\83@\83C\83\8b\82ð\92¼\82É\82¢\82\82é
76     function ExecuteFile(datfilepath : String; firstres : Integer; count : Integer) : Boolean; overload; //DAT\83t\83@\83C\83\8b\82ð\92¼\82É\82¢\82\82é
77     function ReverseExecuteFile(datfilepath : String) : Boolean; overload; //DAT\83t\83@\83C\83\8b\82ð\92¼\82É\82¢\82\82é
78     function ReverseExecuteFile(datfilepath : String; resnum : Integer) : Boolean; overload; //DAT\83t\83@\83C\83\8b\82ð\92¼\82É\82¢\82\82é
79     function ReverseExecuteFile(datfilepath : String; firstres : Integer; count : Integer) : Boolean; overload; //DAT\83t\83@\83C\83\8b\82ð\92¼\82É\82¢\82\82é
80     //--
81     procedure EditNGwords();  //NGword.txt\82ð\8aJ\82­\81B
82     function ShowAllTokens() : String;  //\83f\83o\83b\83O\97p
83     //--
84     procedure GoHome();//List\82Ì\82P\8ds\96Ú\82ð\93Ç\82Þ
85     function GoForward() : Boolean; //List\82Ì\88ê\82Â\8e\9f\82ÌNG\83\8f\81[\83h\83t\83@\83C\83\8b\82ð\93Ç\82Ý\8d\9e\82Þ
86     function GoBack() : Boolean; //List\82Ì\88ê\82Â\91O\82ÌNG\83\8f\81[\83h\83t\83@\83C\83\8b\82ð\93Ç\82Ý\8d\9e\82Þ
87   end;
88 var
89     Abon1 :TAbon;
90 const
91     NGwordListFileName : String = 'NGwords.list';
92
93 implementation
94
95 constructor TAbon.Create;
96 begin
97     // \8f\89\8aú\89»
98     FAbonString := '&nbsp;<>&nbsp;<>&nbsp;<>&nbsp;&nbsp;<><>';
99     FCreateNGwordFile := true;
100     SetLength(FAbonRes,1);
101     FAbonRes[0].Res := 0;
102     FAbonRes[0].option := -1;
103
104 end;
105
106 destructor TAbon.Destroy;
107 begin
108     inherited;
109 end;
110 //root\82ÍExe\config\NGwords\83t\83H\83\8b\83_
111 procedure TAbon.Setroot(root :String);
112 var
113     bufStringList : TStringList;
114 begin
115     bufStringList := TStringList.Create;
116     try
117         if not DirectoryExists(root) then begin
118             CreateDir(root);
119         end;
120         if root[Length(root)] <> '\' then begin
121             root := root + '\';
122         end;
123         Flistpath := root + NGwordListFileName;
124         LoadListFile(Flistpath, bufStringList);
125     finally
126         bufStringList.Free;
127     end;
128     Froot := root;
129 end;
130 function TAbon.Getroot() : String;
131 begin
132     Result := Froot;
133 end;
134 //NGwordpath\82ÍNGword.txt\82Ì\83t\83\8b\83p\83X
135 procedure TAbon.SetNGwordpath(path :String);
136 begin
137     FNGwordpath := Getfullpath(path);
138     LoadFromNGwordFile(FNGwordpath);
139 end;
140 function TAbon.GetNGwordpath() : String;
141 begin
142     Result :=  FNGwordpath;
143 end;
144 //\83t\83\8b\83p\83X\82Å\82È\82¯\82ê\82Î\83t\83\8b\83p\83X\82É\82µ\82Ä\95Ô\82·\81B
145 function TAbon.Getfullpath(argpath : String) : String;
146 begin
147     if AnsiPos(':\',argpath) <> 2 then begin  //\83h\83\89\83C\83u\82©\82ç\82Ì\83t\83\8b\83p\83X\82ª\96³\82¯\82ê\82Î
148         if Getroot() = '' then begin
149             Result := '';    //root\83p\83X\82ª\90Ý\92è\82³\82ê\82Ä\82È\82¢\82©\8bó\82É\82·\82é
150         end else begin
151             if (Froot[Length(Froot)] = '\') and (argpath[1] = '\') then begin  //\90æ\93ª\82Ì\\82ð\8dí\8f\9c
152                 Delete(argpath,1,1);
153             end;
154             Insert( Getroot(), argpath , 1);//root\83p\83X\82ð\91}\93ü
155             Result := argpath;
156         end;
157     end else begin
158         Result := argpath;
159     end;
160
161 end;
162 //NGword\83t\83@\83C\83\8b\82Ì\93Ç\82Ý\8d\9e\82Ý
163 function TAbon.LoadFromNGwordFile(path :String) : boolean;
164 var
165     bufstl : TStringList;
166 begin
167     path := Getfullpath(path);
168     if path = '' then begin
169         Result := false;
170     end else begin
171         bufstl := TStringList.Create;
172         try
173             try
174                 bufstl.LoadFromFile(path);
175                 LoadFromStringList( bufstl );
176                 Result := true;
177             except
178                 if CreateNGwordFile = true then begin
179                     bufstl.SaveToFile(path);
180                 end;
181                 Result := false;
182             end;
183         finally
184             bufstl.Free;
185         end;
186     end;
187
188 end;
189 //NGword\83\8a\83X\83g\93Ç\82Ý\8d\9e\82Ý
190 procedure TAbon.LoadFromStringList( bufstl : TStringList );
191 var
192     i : integer;
193 begin
194     try
195         for i := bufstl.Count -1  downto 0 do begin
196             if bufstl.Strings[i] = '' then begin
197                 bufstl.Delete(i);
198             end;
199         end;
200         SetLength(Ftokens,bufstl.Count);
201         for i := 0  to bufstl.Count -1 do begin
202             SetTokens(i , bufstl.Strings[i]);
203         end;
204
205     except
206         Exit;
207     end;
208 end;
209 //NGwordpath\82ª\8aù\82É\90Ý\92è\82³\82ê\82Ä\82¢\82é\82Æ\82«\82Ì\83\8a\83\8d\81[\83h\97p\8aÖ\90\94
210 function TAbon.ReLoadFromNGwordFile() : boolean;
211 begin
212     if GetNGwordpath() ='' then begin
213         Result := false;
214     end else begin
215         Result := LoadFromNGwordFile( GetNGwordpath() );
216     end;
217 end;
218 function TAbon.Getlistpath() : String;
219 begin
220     Result := Flistpath;
221 end;
222 procedure TAbon.Setlistpath(const Value : String);
223 begin
224     Flistpath := Getfullpath(Value);
225 end;
226 //\88ê\8ds\82Ì\92\86\82Ì\83g\81[\83N\83\93\82ð\90Ø\82è\95ª\82¯\82Ä\83Z\83b\83g
227 procedure TAbon.SetTokens(index: integer ; argline : String);
228 var
229     ret : Integer;
230     bufstl : TStringList;
231     i : Integer;
232     pos : Integer;
233     buftoken : String;
234 begin
235     pos := 0;
236     bufstl := TStringList.Create;
237     try
238         if Length(argline) > 0 then begin
239                 pos := AnsiPos(#9,argline);
240             while pos <> 0 DO begin
241                 buftoken := Copy(argline,1,pos-1);
242                 Delete(argline,1,pos);
243                 if Length(buftoken) > 0 then begin
244                                 bufstl.Append(buftoken);
245                 end;
246                     pos := AnsiPos(#9,argline);
247             end;
248                 if Length(argline) > 0 then begin
249                         bufstl.Append(argline);
250             end;
251                 ret := bufstl.Count;
252                 SetLength(Ftokens[index],ret);
253                 for i := 0 to bufstl.Count - 1  do begin
254                         Ftokens[index][i] := bufstl.Strings[i];
255                 end;
256         end;
257     finally
258         bufstl.Free;
259     end;
260
261 end;
262 //Debug\97p\82¿\82á\82ñ\82ÆNG\83\8f\81[\83h\82ð\8fE\82¦\82Ä\82¢\82é\82©
263 function TAbon.ShowAllTokens() : String;
264 var
265     i : Integer;
266     j : Integer;
267     ret : String;
268 begin
269     for i := 0 to High(Ftokens) do begin
270         for j := 0 to High(Ftokens[i]) do begin
271             ret := ret + Ftokens[i][j];
272         end;
273     end;
274     Result := ret;
275
276
277
278 end;
279
280 //****************************************************************************//
281 //NG\83\8f\81[\83h\82ª\8aÜ\82Ü\82ê\82Ä\82½\82çtrue\82ð\95Ô\82·\81B
282 function TAbon.FindNGwords(line : String) : Boolean;
283 var
284     lines : Integer;
285     cells : Integer;
286     hit : Boolean;
287     bufline : String;
288 begin
289     hit := false;
290     if AnsiPos(FAbonString,line) <> 1 then begin
291         for lines := 0 to High(Ftokens) do begin
292             if High(Ftokens[lines]) > 0 then begin
293                     hit := true;
294                 bufline := line;
295                     for cells := 0 to High(Ftokens[lines]) do begin
296                     if AnsiPos(Ftokens[lines][cells],bufline) = 0 then begin
297                             hit := false;
298                         break;
299                         end else begin
300                         Delete(bufline,AnsiPos(Ftokens[lines][cells],bufline),Length(Ftokens[lines][cells]));
301                         end;
302                 end;
303                     if hit = true then begin
304                     break;
305                 end;
306             end else begin
307                 hit := false;
308             end;
309         end;
310     end;
311     Result := hit;
312
313 end;
314 //CutOff\92l\88È\8fã\8cÂ\82Ì\93¯\82\89p\90\94\82ª\95À\82ñ\82Å\82¢\82½\82çtrue
315 function TAbon.Cutoff(line : String) : Boolean;
316 var
317     i : Integer;
318     sheed : AnsiChar;
319     buf : String;
320     ret : Bool;
321 begin
322     ret := false;
323     if FCutoffNum <> 0 then begin
324         for i := 65 to 90 do begin
325             sheed := Chr(i);
326             buf := DupeString(sheed, FCutoffNum);
327             if AnsiContainsText(line, buf) = true then begin
328                 ret := true;
329                 break;
330             end;
331         end;
332     end;
333     Result := ret;
334 end;
335 //\96\96\94ö\82Ì\83u\81[\83\8b\92l\82Ítrue\82¾\82Æ\81ANG\83\8f\81[\83h\82ð\8aÜ\82Þ\82à\82Ì\82¾\82¯\82ð\95Ô\82·\81B
336 procedure TAbon.Execute(var ThreadStrings : TStringList);
337 var
338     i : Integer;
339     bufline : String;
340 begin
341     //FRetStrings.Clear;
342
343     for i:=0 to ThreadStrings.Count - 1 do begin
344         if FindNGwords(ThreadStrings.Strings[i]) <> Reverse  then begin
345             ThreadStrings.Strings[i] := FAbonString;
346         end else begin
347             bufline := ThreadStrings.Strings[i];
348             if Deleterlo = true then begin
349                 bufline := AnsiReplaceText( bufline,'&rlo;','' );
350             end;
351             if Replaceul = true then begin
352                 bufline := AnsiReplaceText( bufline,'<ul>','<br>' );
353                 bufline := AnsiReplaceText( bufline,'</ul>','<br>' );
354             end;
355             ThreadStrings.Strings[i] := bufline;
356         end;
357     end;
358
359 end;
360 procedure TAbon.Execute(var ThreadStrings : TStringList; NGwords : TStringList);
361 var
362     i : Integer;
363 begin
364     SetLength(Ftokens,NGwords.Count);
365     for i := 0  to NGwords.Count -1 do begin
366         SetTokens(i , NGwords.Strings[i]);
367     end;
368     Execute(ThreadStrings);
369
370 end;
371 procedure TAbon.Execute(var ThreadStrings : TStringList; NGwords : TStrings);
372 var
373     i : Integer;
374     buf : TStringList;
375 begin
376     buf := TStringList.Create;
377     buf.AddStrings(NGwords);
378     SetLength(Ftokens,buf.Count);
379     for i := 0  to buf.Count -1 do begin
380         SetTokens(i , buf.Strings[i]);
381     end;
382     Execute(ThreadStrings);
383     buf.Free;
384 end;
385
386
387 //****************************************************************************//
388 //DAT\82ð\92¼\82É\82¢\82\82é\93z\82ç===========================================================
389 //NG\83\8f\81[\83h\82ð\8aÜ\82Þ\83\8c\83X\82Ì\90æ\93ª\82É\82 \82Ú\81[\82ñ\82ð\91}\93ü
390 function TAbon.ExecuteFile(datfilepath : String; NGwordpath : String) : Boolean; //DAT\83t\83@\83C\83\8b\82ð\92¼\82É\82¢\82\82é
391 var
392     datstl : TStringList;
393     ret : Boolean;
394     i : Integer;
395 begin
396     datstl := TStringList.Create;
397     ret := true;
398     try
399         try
400             datstl.LoadFromFile(datfilepath);
401             for i := 0 to datstl.Count -1 do begin
402                 if FindNGwords(datstl.Strings[i]) = true  then begin
403                     datstl.Strings[i] := FAbonString + datstl.Strings[i]
404                 end;
405             end;
406
407             datstl.SaveToFile(datfilepath);
408         except
409             ret := false;
410         end;
411     finally
412         datstl.Free;
413     end;
414     Result := ret;
415
416 end;
417 //\8ew\92è\82³\82ê\82½\83\8c\83X\94Ô\82Ì\90æ\93ª\82É\82 \82Ú\81[\82ñ\91}\93ü
418 function TAbon.ExecuteFile(datfilepath : String; resnum : Integer) : Boolean; //DAT\83t\83@\83C\83\8b\82ð\92¼\82É\82¢\82\82é
419 var
420     datstl : TStringList;
421     ret : Boolean;
422 begin
423     ret := true;
424     datstl := TStringList.Create;
425     try
426         try
427             datstl.LoadFromFile(datfilepath);
428             if (resnum > 0) and (resnum <= datstl.Count) then begin
429                 if AnsiPos(FAbonString, datstl.Strings[resnum-1]) <> 1 then begin
430                     datstl.Strings[resnum-1] := FAbonString + datstl.Strings[resnum-1];
431                 end;
432             end;
433             datstl.SaveToFile(datfilepath);
434         except
435             ret := false;
436         end;
437     finally
438         datstl.Free;
439     end;
440     Result := ret;
441 end;
442 //firstres\82©\82çcount\8cÂ\82Ì\83\8c\83X\82Ì\90æ\93ª\82É\82 \82Ú\81[\82ñ\91}\93ü
443 function TAbon.ExecuteFile(datfilepath : String; firstres : Integer; count : Integer) : Boolean; //DAT\83t\83@\83C\83\8b\82ð\92¼\82É\82¢\82\82é
444 var
445     datstl : TStringList;
446     i : Integer;
447     endnum : Integer; //\8fI\82í\82è\82Ì\83\8c\83X\94Ô
448     ret : Boolean;
449 begin
450     ret := true;
451     datstl := TStringList.Create;
452     try
453         try
454             datstl.LoadFromFile(datfilepath);
455             if (firstres > 0) and (firstres <= datstl.Count) then begin
456                 if firstres + count -1 > datstl.Count then begin
457                     endnum := datstl.Count;
458                 end else if count <= 0 then begin
459                     endnum := firstres + 1;
460                 end else begin
461                     endnum := firstres + count -1;
462                 end;
463
464                 for i := firstres to endnum do begin
465                     if AnsiPos(FAbonString, datstl.Strings[i-1]) <> 1 then begin
466                         datstl.Strings[i-1] := FAbonString + datstl.Strings[i-1];
467                     end;
468                 end;
469             end;
470             datstl.SaveToFile(datfilepath);
471         except
472             ret := false;
473         end;
474     finally
475         datstl.Free;
476     end;
477     Result := ret;
478 end;
479 //DAT\82ð\92¼\82É\82¢\82\82é\93z\82ç==========\82±\82±\82Ü\82Å=========================================
480
481 //\8c³\82É\96ß\82·\93z\82ç==================================================================
482 function TAbon.ReverseExecuteFile(datfilepath : String) : Boolean; //DAT\83t\83@\83C\83\8b\82ð\92¼\82É\82¢\82\82é
483 var
484     datstl : TStringList;
485     i : Integer;
486     buf : String;
487     ret : Boolean;
488 begin
489     ret := true;
490     datstl := TStringList.Create;
491     try
492         try
493             datstl.LoadFromFile(datfilepath);
494             for i:=0 to datstl.Count -1  do begin
495                 if AnsiPos(FAbonString, datstl.Strings[i]) = 1 then begin
496                     buf := datstl.Strings[i];
497                     Delete(buf,1,Length(FAbonString));
498                     datstl.Strings[i] := buf;
499                 end;
500             end;
501             datstl.SaveToFile(datfilepath);
502         except
503             ret := false;
504         end;
505     finally
506         datstl.Free;
507     end;
508     Result := ret;
509
510 end;
511 function TAbon.ReverseExecuteFile(datfilepath : String; resnum : Integer) : Boolean; //DAT\83t\83@\83C\83\8b\82ð\92¼\82É\82¢\82\82é
512 var
513     datstl : TStringList;
514     buf : String;
515     ret : Boolean;
516 begin
517     ret := true;
518     datstl := TStringList.Create;
519     try
520         try
521             datstl.LoadFromFile(datfilepath);
522             if (resnum > 0) and (resnum <= datstl.Count) then begin
523                 if AnsiPos(FAbonString, datstl.Strings[resnum-1]) = 1 then begin
524                     buf := datstl.Strings[resnum-1];
525                     Delete(buf,1,Length(FAbonString));
526                     datstl.Strings[resnum-1] := buf;
527                 end;
528             end;
529             datstl.SaveToFile(datfilepath);
530         except
531             ret := false;
532         end;
533     finally
534         datstl.Free;
535     end;
536     Result := ret;
537
538 end;
539 function TAbon.ReverseExecuteFile(datfilepath : String; firstres : Integer; count : Integer) : Boolean;//DAT\83t\83@\83C\83\8b\82ð\92¼\82É\82¢\82\82é
540 var
541     datstl : TStringList;
542     i : Integer;
543     endnum : Integer; //\8fI\82í\82è\82Ì\83\8c\83X\94Ô
544     buf : String;
545     ret : Boolean;
546 begin
547     ret := true;
548     datstl := TStringList.Create;
549     try
550         try
551             datstl.LoadFromFile(datfilepath);
552             if (firstres > 0) and (firstres <= datstl.Count) then begin
553                 if firstres + count -1 > datstl.Count then begin
554                     endnum := datstl.Count;
555                 end else if count <= 0 then begin
556                     endnum := firstres + 1;
557                 end else begin
558                     endnum := firstres + count -1;
559                 end;
560                 for i := firstres to endnum do begin
561                     if AnsiPos(FAbonString, datstl.Strings[i-1]) = 1 then begin
562                         buf := datstl.Strings[i-1];
563                         Delete(buf,1,Length(FAbonString));
564                         datstl.Strings[i-1] := buf;
565                     end;
566                 end;
567             end;
568             datstl.SaveToFile(datfilepath);
569         except
570             ret := false;
571         end;
572     finally
573         datstl.Free;
574     end;
575     Result := ret;
576 end;
577 //\8c³\82É\96ß\82·\93z\82ç=================\82±\82±\82Ü\82Å=========================================
578 //\8c»\8dÝ\83Z\83b\83g\82³\82ê\82Ä\82¢\82éNGword.txt\82ð\8aJ\82­
579 procedure TAbon.EditNGwords();
580 begin
581     ShellExecute(0 ,nil,PChar(FNGwordpath),nil,nil,SW_SHOW);
582 end;
583 //\83|\83b\83v\83A\83b\83v\97p\94»\92è\8aÖ\90\94
584 function TAbon.CheckAbonPopupRes(line : String) :Boolean;
585 begin
586     if AbonPopupRes = true then begin
587         Result := FindNGwords(line);
588     end else begin
589         Result := false;
590     end;
591 end;
592 //\95¡\90\94\82ÌNG\83\8f\81[\83h\83e\83L\83X\83g\82ð\93Ç\82Ý\8d\9e\82Þ==============================================
593 //List\83t\83@\83C\83\8b\82ð\93Ç\82Ý\8d\9e\82Þ
594 function TAbon.LoadListFile(path :String; listStringList : TStringList) : Boolean;
595 begin
596     try
597         listStringList.LoadFromFile(path);
598         Result := true;
599     except
600         listStringList.Append('\88ê\94Ê=NGword.txt');
601         listStringList.SaveToFile(path);
602         Result := false;
603     end;
604 end;
605 //List\82Ì\88ê\82Â\8e\9f\82ÌNG\83\8f\81[\83h\83t\83@\83C\83\8b\82ð\93Ç\82Ý\8d\9e\82Þ
606 function TAbon.GoForward() : Boolean;
607 begin
608     FNGwordFileIndex := FNGwordFileIndex + 1;
609     Result := ReadNGwordslist(FNGwordFileIndex);
610 end;
611 //List\82Ì\88ê\82Â\91O\82ÌNG\83\8f\81[\83h\83t\83@\83C\83\8b\82ð\93Ç\82Ý\8d\9e\82Þ
612 function TAbon.GoBack() : Boolean;
613 begin
614     FNGwordFileIndex := FNGwordFileIndex -1;
615     Result := ReadNGwordslist(FNGwordFileIndex);
616 end;
617 //List\82Ì\82P\8ds\96Ú\82ð\93Ç\82Þ
618 procedure TAbon.GoHome();
619 begin
620     FNGwordFileIndex := 0;
621     ReadNGwordslist(FNGwordFileIndex);
622 end;
623 //List\82Ìline\8ds\96Ú\82ð\93Ç\82Þ
624 function TAbon.ReadNGwordslist(line : Integer) : Boolean;
625 var
626     liststl : TStringList;
627     linebuf : String;
628 begin
629     liststl := TStringList.Create;
630     try
631         if LoadListFile(Flistpath,liststl) = true then begin
632             if line < 0 then begin
633                 line := liststl.Count - 1;
634                 FNGwordFileIndex := liststl.Count - 1;
635             end else if line > liststl.Count - 1 then begin
636                 line := 0;
637                 FNGwordFileIndex := 0;
638             end;
639             linebuf := liststl.Strings[line];
640             FNGwordname := Copy(linebuf,1,AnsiPos('=',linebuf)-1);
641             Delete(linebuf,1,AnsiPos('=',linebuf));
642             SetNGwordpath(linebuf);
643             Result := true;
644         end else begin
645             Result := false;
646         end
647     finally
648         liststl.Free;
649     end;
650
651 end;
652 //\95¡\90\94\82ÌNG\83\8f\81[\83h\83e\83L\83X\83g\82ð\93Ç\82Ý\8d\9e\82Þ=====\82±\82±\82Ü\82Å=================================
653 //\8cÂ\95Ê\82 \82Ú\81`\82ñ\8eÀ\8ds\8aÖ\90\94
654 procedure TAbon.IndividualAbon(var ThreadStrings : TStringList; SetResNumFile : String);
655 var
656         i : Integer;
657 begin
658         if FileExists(SetResNumFile) = true then begin
659         if LoadFromSetResNumFile(SetResNumFile) = true then begin
660                 for i := 0 to High(FAbonRes) do begin
661                  if (FAbonRes[i].Res <= ThreadStrings.Count) and (FAbonRes[i].Res > 0) then begin
662                         if FAbonRes[i].option = 0 then begin
663                         ThreadStrings.Strings[FAbonRes[i].Res-1] := '';
664                     end else begin
665                         ThreadStrings.Strings[FAbonRes[i].Res-1] := '\82 \82Ú\81`\82ñ<>\82 \82Ú\81`\82ñ<>\82 \82Ú\81`\82ñ<>\82 \82Ú\81`\82ñ<>';
666                     end;
667                  end;
668
669             end;
670         end;
671     end else begin
672         FIndividualFileName := SetResNumFile;
673         SetLength(FAbonRes,1);
674         FAbonRes[0].Res := 0;
675         FAbonRes[0].option := -1;
676     end;
677 end;
678 //\8cÂ\95Ê\82 \82Ú\81`\82ñ\83t\83@\83C\83\8b\93Ç\82Ý\8d\9e\82Ý\8aÖ\90\94
679 function TAbon.LoadFromSetResNumFile(SetResNumFile : String) : Boolean;
680 var
681         bufStringList : TStringList;
682     bufLine : String;
683     i : Integer;
684 begin
685     bufStringList := TStringList.Create;
686     try
687         try
688                 bufStringList.LoadFromFile(SetResNumFile);
689             FIndividualFileName := SetResNumFile;
690             //\8bó\8ds\8dí\8f\9c
691             for i := bufStringList.Count-1 downto 0 do begin
692                         if bufStringList.Strings[i] = '' then begin
693                         bufStringList.Delete(i);
694                     end;
695             end;
696
697             //\83\81\83\82\83\8a\8am\95Û
698                 SetLength(FAbonRes,bufStringList.Count);
699             //\91ã\93ü
700             for i :=0 to bufStringList.Count - 1 do begin
701                         bufLine := Trim(bufStringList.Strings[i]);
702                     FAbonRes[i].Res :=  StrToInt(Copy(bufLine,1,AnsiPos('-',bufLine)-1));
703                 FAbonRes[i].option := StrToInt(Copy(bufLine,AnsiPos('-',bufLine)+1,1));
704             end;
705         except
706                 Result := false;
707             Exit;
708         end;
709     finally
710         bufStringList.Free;
711     end;
712     Result := true;
713 end;
714 //\8cÂ\95Ê\82 \82Ú\81`\82ñ\83t\83@\83C\83\8b\82É\92Ç\89Á
715 procedure TAbon.AddIndividualAbon( ResNum : Integer ; option : Integer);
716 var
717         IndividualFile : TStringList;
718     linebuf : String;
719     i : Integer;
720 begin
721     IndividualFile := TStringList.Create;
722         if FAbonRes[0].Res <> 0 then begin
723         for i := 0 to High(FAbonRes) do begin
724             if FAbonRes[i].Res <> ResNum then begin
725                         linebuf := IntToStr(FAbonRes[i].Res) + '-' + IntToStr(FabonRes[i].option);
726                 IndividualFile.Append(linebuf);
727             end;
728         end;
729     end;
730     linebuf := IntToStr(ResNum) + '-' + IntToStr(option);
731     IndividualFile.Append(linebuf);
732     try
733         IndividualFile.SaveToFile(FIndividualFileName);
734     finally
735         IndividualFile.Free;
736     end;
737 end;
738 //\8cÂ\95Ê\82 \82Ú\81`\82ñ\83t\83@\83C\83\8b\82©\82ç\8dí\8f\9c
739 procedure TAbon.DeleteIndividualAbon( ResNum : Integer);
740 var
741         IndividualFile : TStringList;
742     linebuf : String;
743     i : Integer;
744 begin
745     IndividualFile := TStringList.Create;
746         if FAbonRes[0].Res <> 0 then begin
747         for i := 0 to High(FAbonRes) do begin
748             if FAbonRes[i].Res <> ResNum then begin
749                         linebuf := IntToStr(FAbonRes[i].Res) + '-' + IntToStr(FabonRes[i].option);
750                 IndividualFile.Append(linebuf);
751             end;
752         end;
753     end;
754         if IndividualFile.Count <> 0 then begin
755         try
756                 IndividualFile.SaveToFile(FIndividualFileName);
757         finally
758                 IndividualFile.Free;
759         end;
760     end else begin
761         if FileExists(FIndividualFileName) = true then begin
762                 DeleteFile(FIndividualFileName);
763         end;
764     end;
765 end;
766 //\8cÂ\95Ê\82 \82Ú\81`\82ñ\82Ì\83\8a\83X\83g\82Ì\8cÂ\90\94\82ð\95Ô\82·
767 function TAbon.GetAbonResCount() : Integer;
768 var
769         i : Integer;
770 begin
771     if FAbonRes[0].Res = 0 then begin
772         Result := 0
773     end else begin
774                 i := High(FAbonRes);
775         Result := i+1;
776     end;
777 end;
778 //\8cÂ\95Ê\82 \82Ú\81`\82ñ\82Ì\83\8a\83X\83g\82Ì\82\8e\8ds\96Ú\82Ì\83\8c\83X\82ð\95\8e\9a\97ñ\82Å\95Ô\82·
779 function TAbon.GetAbonResString(Num : Integer) : String;
780 begin
781         if (Num <= High(FAbonRes)) and (Num >= 0) then begin
782         Result := IntToStr(FAbonRes[Num].Res);
783     end else begin
784         Result := '';
785     end;
786 end;
787 //\83|\83b\83v\83A\83b\83v\82Ì\94»\92è\97p
788 function TAbon.CheckIndividualAbonList(ResNum : Integer) : Boolean;
789 var
790         i : Integer;
791 begin
792         if FAbonRes[0].Res <> 0 then begin
793         for i := 0 to High(FAbonRes) do begin
794                 if FAbonRes[i].Res = ResNum then begin
795                 Result := true;
796                 Exit;
797             end;
798         end;
799     end;
800     Result := false;
801     
802 end;
803 end.
804