Develop and Download Open Source Software

Browse CVS Repository

Annotation of /gikonavigoeson/gikonavi/AbonUnit.pas

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.18 - (hide annotations) (download) (as text)
Wed Nov 19 18:29:45 2003 UTC (20 years, 5 months ago) by h677
Branch: MAIN
Changes since 1.17: +64 -2 lines
File MIME type: text/x-pascal
NGワードでの透明あぼ〜んの実装

1 h677 1.1 unit AbonUnit;
2    
3     interface
4     uses
5 h677 1.2 Windows,Messages, ShellAPI, SysUtils, Classes,StdCtrls,StrUtils;
6 h677 1.1
7     type
8 h677 1.11 TIndiviAbon = record
9     Res: Integer;
10     option: Integer; // 0:?? 1:??絽吾???若?若??
11     end;
12    
13 h677 1.1 TAbon = class(TObject)
14     private
15     { Private 絎h? }
16     Froot : String;
17 h677 1.9 Flistpath : String;
18 h677 1.1 FNGwordpath : String;
19 h677 1.2 Ftokens : array of array of string;
20 h677 1.11 FAbonRes : array of TIndiviAbon;
21 h677 1.1 FAbonString : String;
22 h677 1.2 FCutoffNum : Integer; //?????遺札筝??g??????????怨???NG???若????????
23 h677 1.17 FDeleterlo : Boolean; //&rlo;???????? //菴遵??&lro;??????
24 h677 1.3 FReplaceul :Boolean ; //<ul>?帥?違??<br>?帥?違??舟????????
25     FReverse : Boolean ; //NG???若???с?????若?????????????荵≪????????
26     FAbonPopupRes : Boolean; //???鴻???????≪?????????????若?若????????
27     FCreateNGwordFile : Boolean; //??絎???????path??G???若??txt???<???c??????????????????????????
28 h677 1.9 FNGwordFileIndex : Integer; //?上????粋昭???с??NG???若????list???茵?????
29     FNGwordname : String; //?上????粋昭???с??NG???若????;腓阪??
30 h677 1.11 FIndividualFileName : String; //???ャ???若?????????<?ゃ????
31 h677 1.16 FReturnNGwordLineNum : Boolean; //NG???若??????違??菴?????
32     FSetNGResAnchor : Boolean; //NG???綵????????????????????????鴻?吾?????鴻?≪?潟???若???ゃ????????????
33 h677 1.1 procedure SetTokens(index: integer ; argline:String);
34 h677 1.9 function Getlistpath() : String;
35     procedure Setlistpath(const Value : String);
36     function LoadListFile(path :String;listStringList : TStringList) : Boolean;
37 h677 1.10 function ReadNGwordslist(line : Integer) : Boolean;
38 h677 1.11 function LoadFromSetResNumFile(SetResNumFile : String) : Boolean;
39 h677 1.1 public
40     { Public 絎h? }
41     constructor Create; // ?潟?潟?鴻????????/span>
42     destructor Destroy; override; // ???鴻????????/span>
43 h677 1.3 property Deleterlo: Boolean read FDeleterlo write FDeleterlo default false;
44     property Replaceul: Boolean read FReplaceul write FReplaceul default false;
45     property Reverse: Boolean read FReverse write FReverse default false;
46 h677 1.4 property CreateNGwordFile: Boolean read FCreateNGwordFile write FCreateNGwordFile;
47 h677 1.3 property AbonString : String read FAbonString write FAbonString;
48     property AbonPopupRes : Boolean read FAbonPopupRes write FAbonPopupRes default false;
49 h677 1.9 property listpath : String read Getlistpath write Setlistpath;
50     property NGwordFileIndex : Integer read FNGwordFileIndex write FNGwordFileIndex default 0;
51     property NGwordname : String read FNGwordname write FNGwordname;
52 h677 1.16 property ReturnNGwordLineNum : Boolean read FReturnNGwordLineNum write FReturnNGwordLineNum default false;
53     property SetNGResAnchor : Boolean read FSetNGResAnchor write FSetNGResAnchor default false;
54 h677 1.1 procedure Setroot(root :String);
55     function Getroot() : String;
56 h677 1.9
57     function Getfullpath(argpath : String) : String;
58 h677 1.1 procedure SetNGwordpath(path :String);
59     function GetNGwordpath() : String;
60     function LoadFromNGwordFile(path :String) : Boolean;
61     function ReLoadFromNGwordFile() : Boolean;
62 yoffy 1.6 procedure LoadFromStringList( bufstl : TStringList );
63 h677 1.3 function CheckAbonPopupRes(line : String) :Boolean;
64 h677 1.16 function FindNGwords(line : String) : Boolean; overload;//1???ゃ?潟???ょ????
65     function FindNGwords(line : String; var NGwordsLineNum : Integer) : Boolean; overload;//1???ゃ?潟???ょ????
66 h677 1.18 function FindNGwords(line : String; var NGwordsLineNum : Integer; var Invisible : Boolean) : Boolean; overload;//1???ゃ?潟???ょ????
67 h677 1.3 function Cutoff(line : String) : Boolean; //CutOff?や札筝??????????掩?違??筝????с??????true
68 h677 1.11 //???若????????(NG???若???с?????c???帥???潟??
69 h677 1.7 procedure Execute(var ThreadStrings : TStringList); overload;
70     procedure Execute(var ThreadStrings : TStringList; NGwords : TStringList); overload;
71     procedure Execute(var ThreadStrings : TStringList; NGwords : TStrings); overload;
72 h677 1.11 //???ャ???若??????????
73     procedure IndividualAbon(var ThreadStrings : TStringList; SetResNumFile : String);
74     procedure AddIndividualAbon( ResNum : Integer ; option : Integer);
75     procedure DeleteIndividualAbon( ResNum : Integer);
76     function GetAbonResCount() : Integer;
77     function GetAbonResString(Num : Integer) : String;
78 h677 1.12 function CheckIndividualAbonList(ResNum : Integer) : Boolean;
79 h677 1.1 //--
80     function ExecuteFile(datfilepath : String; NGwordpath : String) : Boolean; overload;//DAT???<?ゃ?????眼????????
81     function ExecuteFile(datfilepath : String; resnum : Integer) : Boolean; overload; //DAT???<?ゃ?????眼????????
82     function ExecuteFile(datfilepath : String; firstres : Integer; count : Integer) : Boolean; overload; //DAT???<?ゃ?????眼????????
83     function ReverseExecuteFile(datfilepath : String) : Boolean; overload; //DAT???<?ゃ?????眼????????
84     function ReverseExecuteFile(datfilepath : String; resnum : Integer) : Boolean; overload; //DAT???<?ゃ?????眼????????
85     function ReverseExecuteFile(datfilepath : String; firstres : Integer; count : Integer) : Boolean; overload; //DAT???<?ゃ?????眼????????
86     //--
87     procedure EditNGwords(); //NGword.txt???????
88     function ShowAllTokens() : String; //???????亥??/span>
89 h677 1.9 //--
90     procedure GoHome();//List???茵?????茯???
91     function GoForward() : Boolean; //List????ゆ???G???若?????<?ゃ????茯??粋昭??
92     function GoBack() : Boolean; //List????ゅ????G???若?????<?ゃ????茯??粋昭??
93 h677 1.1 end;
94     var
95     Abon1 :TAbon;
96 h677 1.9 const
97     NGwordListFileName : String = 'NGwords.list';
98 h677 1.1
99     implementation
100    
101     constructor TAbon.Create;
102     begin
103     // ??????
104     FAbonString := '&nbsp;<>&nbsp;<>&nbsp;<>&nbsp;&nbsp;<><>';
105 h677 1.4 FCreateNGwordFile := true;
106 h677 1.11 SetLength(FAbonRes,1);
107     FAbonRes[0].Res := 0;
108     FAbonRes[0].option := -1;
109    
110 h677 1.1 end;
111    
112     destructor TAbon.Destroy;
113     begin
114     inherited;
115     end;
116 h677 1.9 //root??xe\config\NGwords????????
117 h677 1.1 procedure TAbon.Setroot(root :String);
118 h677 1.9 var
119     bufStringList : TStringList;
120 h677 1.1 begin
121 h677 1.9 bufStringList := TStringList.Create;
122     try
123     if not DirectoryExists(root) then begin
124     CreateDir(root);
125     end;
126     if root[Length(root)] <> '\' then begin
127     root := root + '\';
128     end;
129     Flistpath := root + NGwordListFileName;
130     LoadListFile(Flistpath, bufStringList);
131     finally
132     bufStringList.Free;
133     end;
134 h677 1.1 Froot := root;
135     end;
136     function TAbon.Getroot() : String;
137     begin
138     Result := Froot;
139     end;
140     //NGwordpath??Gword.txt??????????/span>
141     procedure TAbon.SetNGwordpath(path :String);
142     begin
143 h677 1.9 FNGwordpath := Getfullpath(path);
144 h677 1.1 LoadFromNGwordFile(FNGwordpath);
145     end;
146     function TAbon.GetNGwordpath() : String;
147     begin
148     Result := FNGwordpath;
149     end;
150 h677 1.9 //???????鴻?с???????違???????鴻???????????
151     function TAbon.Getfullpath(argpath : String) : String;
152     begin
153     if AnsiPos(':\',argpath) <> 2 then begin //?????ゃ???????????????鴻???<??????/span>
154     if Getroot() = '' then begin
155     Result := ''; //root???鴻??荐??????????????腥冴??????
156     end else begin
157     if (Froot[Length(Froot)] = '\') and (argpath[1] = '\') then begin //????????????/span>
158     Delete(argpath,1,1);
159     end;
160     Insert( Getroot(), argpath , 1);//root???鴻???水??/span>
161     Result := argpath;
162     end;
163     end else begin
164     Result := argpath;
165     end;
166    
167     end;
168 h677 1.1 //NGword???<?ゃ??????粋昭??/span>
169     function TAbon.LoadFromNGwordFile(path :String) : boolean;
170     var
171     bufstl : TStringList;
172     begin
173 h677 1.9 path := Getfullpath(path);
174     if path = '' then begin
175     Result := false;
176     end else begin
177     bufstl := TStringList.Create;
178     try
179     try
180     bufstl.LoadFromFile(path);
181     LoadFromStringList( bufstl );
182     Result := true;
183     except
184     if CreateNGwordFile = true then begin
185     bufstl.SaveToFile(path);
186     end;
187     Result := false;
188 h677 1.1 end;
189 h677 1.9 finally
190     bufstl.Free;
191 h677 1.1 end;
192     end;
193 yoffy 1.6
194     end;
195     //NGword???鴻??茯??粋昭??/span>
196     procedure TAbon.LoadFromStringList( bufstl : TStringList );
197     var
198     i : integer;
199     begin
200     try
201 h677 1.3 for i := bufstl.Count -1 downto 0 do begin
202     if bufstl.Strings[i] = '' then begin
203     bufstl.Delete(i);
204     end;
205     end;
206 h677 1.2 SetLength(Ftokens,bufstl.Count);
207 h677 1.1 for i := 0 to bufstl.Count -1 do begin
208     SetTokens(i , bufstl.Strings[i]);
209     end;
210    
211     except
212     Exit;
213     end;
214     end;
215     //NGwordpath???≪??┃絎??????????????????????若?????∽??/span>
216     function TAbon.ReLoadFromNGwordFile() : boolean;
217     begin
218     if GetNGwordpath() ='' then begin
219     Result := false;
220     end else begin
221     Result := LoadFromNGwordFile( GetNGwordpath() );
222     end;
223     end;
224 h677 1.9 function TAbon.Getlistpath() : String;
225     begin
226     Result := Flistpath;
227     end;
228     procedure TAbon.Setlistpath(const Value : String);
229     begin
230     Flistpath := Getfullpath(Value);
231     end;
232 h677 1.1 //筝?茵???賢?????若???潟?????????????祉????
233     procedure TAbon.SetTokens(index: integer ; argline : String);
234     var
235     ret : Integer;
236     bufstl : TStringList;
237     i : Integer;
238 h677 1.14 pos : Integer;
239     buftoken : String;
240 h677 1.1 begin
241 h677 1.14 pos := 0;
242 h677 1.1 bufstl := TStringList.Create;
243 h677 1.14 try
244     if Length(argline) > 0 then begin
245     pos := AnsiPos(#9,argline);
246     while pos <> 0 DO begin
247     buftoken := Copy(argline,1,pos-1);
248     Delete(argline,1,pos);
249     if Length(buftoken) > 0 then begin
250     bufstl.Append(buftoken);
251 h677 1.18 end else if ( bufstl.Count = 0 ) then begin
252     bufstl.Append('');
253 h677 1.14 end;
254     pos := AnsiPos(#9,argline);
255     end;
256     if Length(argline) > 0 then begin
257     bufstl.Append(argline);
258     end;
259     ret := bufstl.Count;
260     SetLength(Ftokens[index],ret);
261     for i := 0 to bufstl.Count - 1 do begin
262     Ftokens[index][i] := bufstl.Strings[i];
263     end;
264     end;
265     finally
266     bufstl.Free;
267 h677 1.1 end;
268    
269     end;
270 h677 1.8 //Debug???<??????G???若?????障??????????
271 h677 1.1 function TAbon.ShowAllTokens() : String;
272     var
273     i : Integer;
274     j : Integer;
275     ret : String;
276     begin
277 h677 1.2 for i := 0 to High(Ftokens) do begin
278     for j := 0 to High(Ftokens[i]) do begin
279     ret := ret + Ftokens[i][j];
280 h677 1.1 end;
281     end;
282     Result := ret;
283    
284    
285    
286     end;
287    
288     //****************************************************************************//
289     //NG???若???????障????????true??菴?????
290     function TAbon.FindNGwords(line : String) : Boolean;
291     var
292 h677 1.11 lines : Integer;
293     cells : Integer;
294 h677 1.1 hit : Boolean;
295 h677 1.11 bufline : String;
296 h677 1.1 begin
297     hit := false;
298     if AnsiPos(FAbonString,line) <> 1 then begin
299 h677 1.11 for lines := 0 to High(Ftokens) do begin
300 h677 1.15 hit := true;
301     bufline := line;
302     for cells := 0 to High(Ftokens[lines]) do begin
303     if AnsiPos(Ftokens[lines][cells],bufline) = 0 then begin
304     hit := false;
305     break;
306     end else begin
307     Delete(bufline,AnsiPos(Ftokens[lines][cells],bufline),Length(Ftokens[lines][cells]));
308     end;
309     end;
310     if hit = true then begin
311     break;
312 h677 1.1 end;
313     end;
314     end;
315     Result := hit;
316 h677 1.16 end;
317     //NG???若???????障??????????true??菴?????????G???若??????違??NGwordsLineNum???ャ???????
318     function TAbon.FindNGwords(line : String; var NGwordsLineNum : Integer) : Boolean;
319     var
320     lines : Integer;
321     cells : Integer;
322     hit : Boolean;
323     bufline : String;
324     begin
325     hit := false;
326     if AnsiPos(FAbonString,line) <> 1 then begin
327     for lines := 0 to High(Ftokens) do begin
328     hit := true;
329     bufline := line;
330     for cells := 0 to High(Ftokens[lines]) do begin
331     if AnsiPos(Ftokens[lines][cells],bufline) = 0 then begin
332     hit := false;
333     break;
334     end else begin
335     Delete(bufline,AnsiPos(Ftokens[lines][cells],bufline),Length(Ftokens[lines][cells]));
336     end;
337     end;
338     if hit = true then begin
339     NGwordsLineNum := lines + 1;
340     break;
341     end;
342     end;
343     end;
344     Result := hit;
345 h677 1.1 end;
346 h677 1.18 //NG???若???????障??????????true??菴?????????G???若??????違??NGwordsLineNum???ャ?????????
347     //????????????若??????????????Inbisible??true?????????
348     function TAbon.FindNGwords(line : String; var NGwordsLineNum : Integer; var Invisible : Boolean) : Boolean; //1???ゃ?潟???ょ????
349     var
350     lines : Integer;
351     cells : Integer;
352     hit : Boolean;
353     bufline : String;
354     start : Integer;
355     begin
356     hit := false;
357     if AnsiPos(FAbonString,line) <> 1 then begin
358     for lines := 0 to High(Ftokens) do begin
359     hit := true;
360     bufline := line;
361     if Ftokens[lines][0] <> '' then begin
362     Invisible := false;
363     start := 0;
364     end else begin
365     Invisible := true;
366     start := 1;
367     end;
368    
369     for cells := start to High(Ftokens[lines]) do begin
370     if AnsiPos(Ftokens[lines][cells],bufline) = 0 then begin
371     hit := false;
372     break;
373     end else begin
374     Delete(bufline,AnsiPos(Ftokens[lines][cells],bufline),Length(Ftokens[lines][cells]));
375     end;
376     end;
377     if hit = true then begin
378     NGwordsLineNum := lines + 1;
379     break;
380     end;
381     end;
382     end;
383     Result := hit;
384     end;
385    
386 h677 1.3 //CutOff?や札筝??????????掩?違??筝????с??????true
387     function TAbon.Cutoff(line : String) : Boolean;
388 h677 1.2 var
389     i : Integer;
390     sheed : AnsiChar;
391     buf : String;
392 h677 1.3 ret : Bool;
393 h677 1.2 begin
394 h677 1.3 ret := false;
395 h677 1.2 if FCutoffNum <> 0 then begin
396     for i := 65 to 90 do begin
397     sheed := Chr(i);
398     buf := DupeString(sheed, FCutoffNum);
399     if AnsiContainsText(line, buf) = true then begin
400 h677 1.3 ret := true;
401 h677 1.2 break;
402     end;
403     end;
404     end;
405     Result := ret;
406     end;
407 h677 1.1 //??鮎?????若???ゃ??rue??????NG???若??????????????????菴?????
408 h677 1.7 procedure TAbon.Execute(var ThreadStrings : TStringList);
409 h677 1.1 var
410     i : Integer;
411 h677 1.16 NGwordsLine : Integer;
412 h677 1.2 bufline : String;
413 h677 1.18 invisi : Boolean;
414 h677 1.2 begin
415 h677 1.7 //FRetStrings.Clear;
416 h677 1.18 {
417 h677 1.16 if not ReturnNGwordLineNum then begin
418     //if ReturnNGwordLineNum then begin
419     for i:=0 to ThreadStrings.Count - 1 do begin
420     if FindNGwords(ThreadStrings.Strings[i]) <> Reverse then begin
421     if not SetNGResAnchor then
422     ThreadStrings.Strings[i] := FAbonString
423     else
424     ThreadStrings.Strings[i] := Format('&nbsp;<>&nbsp;<>&nbsp;<>&gt;%d<><>',[(i+1)]);
425     end else begin
426     bufline := ThreadStrings.Strings[i];
427     if Deleterlo = true then begin
428     bufline := AnsiReplaceText( bufline,'&rlo;','' );
429 h677 1.17 bufline := AnsiReplaceText( bufline,'&lro;','' );
430 h677 1.16 end;
431     if Replaceul = true then begin
432     bufline := AnsiReplaceText( bufline,'<ul>','<br>' );
433     bufline := AnsiReplaceText( bufline,'</ul>','<br>' );
434     end;
435     ThreadStrings.Strings[i] := bufline;
436     end;
437     end;
438     end else begin
439 h677 1.18 }
440 h677 1.16 for i:=0 to ThreadStrings.Count - 1 do begin
441     NGwordsLine := 0;
442 h677 1.18 if FindNGwords(ThreadStrings.Strings[i], NGwordsLine ,invisi) <> Reverse then begin
443     if invisi = true then begin
444     ThreadStrings.Strings[i] := '';
445     end else begin
446     if not ReturnNGwordLineNum and not SetNGResAnchor then begin
447     ThreadStrings.Strings[i] := FAbonString;
448     end else if not ReturnNGwordLineNum then begin
449     ThreadStrings.Strings[i] := Format('&nbsp;<>&nbsp;<>&nbsp;<>&gt;%d<><>',[(i+1)]);
450     end else if not SetNGResAnchor then begin
451     ThreadStrings.Strings[i] := Format('&nbsp;<>&nbsp;<>&nbsp;<><B> %d 茵?????G???若???????障???????障????</B><><>',[NGwordsLine]);
452     end else begin
453     ThreadStrings.Strings[i] := Format('&nbsp;<>&nbsp;<>&nbsp;<><B> %d 茵?????G???若???????障???????障????</B>&gt;%d <><>',[NGwordsLine,(i+1)]);
454     end;
455     end;
456    
457     {
458 h677 1.16 if not SetNGResAnchor then
459     ThreadStrings.Strings[i] := Format('&nbsp;<>&nbsp;<>&nbsp;<><B> %d 茵?????G???若???????障???????障????</B><><>',[NGwordsLine])
460     else
461     ThreadStrings.Strings[i] := Format('&nbsp;<>&nbsp;<>&nbsp;<><B> %d 茵?????G???若???????障???????障????</B>&gt;%d <><>',[NGwordsLine,(i+1)]);
462 h677 1.18 }
463 h677 1.16 end else begin
464     bufline := ThreadStrings.Strings[i];
465     if Deleterlo = true then begin
466     bufline := AnsiReplaceText( bufline,'&rlo;','' );
467 h677 1.17 bufline := AnsiReplaceText( bufline,'&lro;','' );
468 h677 1.16 end;
469     if Replaceul = true then begin
470     bufline := AnsiReplaceText( bufline,'<ul>','<br>' );
471     bufline := AnsiReplaceText( bufline,'</ul>','<br>' );
472     end;
473     ThreadStrings.Strings[i] := bufline;
474     end;
475     end;
476 h677 1.1
477 h677 1.18 // end;
478 h677 1.1
479     end;
480 h677 1.7 procedure TAbon.Execute(var ThreadStrings : TStringList; NGwords : TStringList);
481 h677 1.1 var
482     i : Integer;
483     begin
484 h677 1.2 SetLength(Ftokens,NGwords.Count);
485 h677 1.1 for i := 0 to NGwords.Count -1 do begin
486     SetTokens(i , NGwords.Strings[i]);
487     end;
488 h677 1.7 Execute(ThreadStrings);
489 h677 1.1
490     end;
491 h677 1.7 procedure TAbon.Execute(var ThreadStrings : TStringList; NGwords : TStrings);
492 h677 1.1 var
493     i : Integer;
494     buf : TStringList;
495     begin
496     buf := TStringList.Create;
497     buf.AddStrings(NGwords);
498 h677 1.2 SetLength(Ftokens,buf.Count);
499 h677 1.1 for i := 0 to buf.Count -1 do begin
500     SetTokens(i , buf.Strings[i]);
501     end;
502 h677 1.7 Execute(ThreadStrings);
503 h677 1.1 buf.Free;
504     end;
505    
506    
507     //****************************************************************************//
508     //DAT???眼????????絅眼??===========================================================
509     //NG???若???????????鴻???????????若?若?????水??/span>
510     function TAbon.ExecuteFile(datfilepath : String; NGwordpath : String) : Boolean; //DAT???<?ゃ?????眼????????
511     var
512     datstl : TStringList;
513     ret : Boolean;
514     i : Integer;
515     begin
516     datstl := TStringList.Create;
517     ret := true;
518     try
519     try
520     datstl.LoadFromFile(datfilepath);
521     for i := 0 to datstl.Count -1 do begin
522     if FindNGwords(datstl.Strings[i]) = true then begin
523     datstl.Strings[i] := FAbonString + datstl.Strings[i]
524     end;
525     end;
526    
527     datstl.SaveToFile(datfilepath);
528     except
529     ret := false;
530     end;
531     finally
532     datstl.Free;
533     end;
534     Result := ret;
535    
536     end;
537     //??絎??????????合?????????????若?若???水??/span>
538     function TAbon.ExecuteFile(datfilepath : String; resnum : Integer) : Boolean; //DAT???<?ゃ?????眼????????
539     var
540     datstl : TStringList;
541     ret : Boolean;
542     begin
543     ret := true;
544     datstl := TStringList.Create;
545     try
546     try
547     datstl.LoadFromFile(datfilepath);
548     if (resnum > 0) and (resnum <= datstl.Count) then begin
549     if AnsiPos(FAbonString, datstl.Strings[resnum-1]) <> 1 then begin
550     datstl.Strings[resnum-1] := FAbonString + datstl.Strings[resnum-1];
551     end;
552     end;
553     datstl.SaveToFile(datfilepath);
554     except
555     ret := false;
556     end;
557     finally
558     datstl.Free;
559     end;
560     Result := ret;
561     end;
562     //firstres????count???????鴻???????????若?若???水??/span>
563     function TAbon.ExecuteFile(datfilepath : String; firstres : Integer; count : Integer) : Boolean; //DAT???<?ゃ?????眼????????
564     var
565     datstl : TStringList;
566     i : Integer;
567     endnum : Integer; //腟?????????合??/span>
568     ret : Boolean;
569     begin
570     ret := true;
571     datstl := TStringList.Create;
572     try
573     try
574     datstl.LoadFromFile(datfilepath);
575     if (firstres > 0) and (firstres <= datstl.Count) then begin
576     if firstres + count -1 > datstl.Count then begin
577     endnum := datstl.Count;
578     end else if count <= 0 then begin
579     endnum := firstres + 1;
580     end else begin
581     endnum := firstres + count -1;
582     end;
583    
584     for i := firstres to endnum do begin
585     if AnsiPos(FAbonString, datstl.Strings[i-1]) <> 1 then begin
586     datstl.Strings[i-1] := FAbonString + datstl.Strings[i-1];
587     end;
588     end;
589     end;
590     datstl.SaveToFile(datfilepath);
591     except
592     ret := false;
593     end;
594     finally
595     datstl.Free;
596     end;
597     Result := ret;
598     end;
599     //DAT???眼????????絅眼??==========?????障??========================================
600    
601     //?????祉??絅眼??==================================================================
602     function TAbon.ReverseExecuteFile(datfilepath : String) : Boolean; //DAT???<?ゃ?????眼????????
603     var
604     datstl : TStringList;
605     i : Integer;
606     buf : String;
607     ret : Boolean;
608     begin
609     ret := true;
610     datstl := TStringList.Create;
611     try
612     try
613     datstl.LoadFromFile(datfilepath);
614     for i:=0 to datstl.Count -1 do begin
615     if AnsiPos(FAbonString, datstl.Strings[i]) = 1 then begin
616     buf := datstl.Strings[i];
617     Delete(buf,1,Length(FAbonString));
618     datstl.Strings[i] := buf;
619     end;
620     end;
621     datstl.SaveToFile(datfilepath);
622     except
623     ret := false;
624     end;
625     finally
626     datstl.Free;
627     end;
628     Result := ret;
629    
630     end;
631     function TAbon.ReverseExecuteFile(datfilepath : String; resnum : Integer) : Boolean; //DAT???<?ゃ?????眼????????
632     var
633     datstl : TStringList;
634     buf : String;
635     ret : Boolean;
636     begin
637     ret := true;
638     datstl := TStringList.Create;
639     try
640     try
641     datstl.LoadFromFile(datfilepath);
642     if (resnum > 0) and (resnum <= datstl.Count) then begin
643     if AnsiPos(FAbonString, datstl.Strings[resnum-1]) = 1 then begin
644     buf := datstl.Strings[resnum-1];
645     Delete(buf,1,Length(FAbonString));
646     datstl.Strings[resnum-1] := buf;
647     end;
648     end;
649     datstl.SaveToFile(datfilepath);
650     except
651     ret := false;
652     end;
653     finally
654     datstl.Free;
655     end;
656     Result := ret;
657    
658     end;
659     function TAbon.ReverseExecuteFile(datfilepath : String; firstres : Integer; count : Integer) : Boolean;//DAT???<?ゃ?????眼????????
660     var
661     datstl : TStringList;
662     i : Integer;
663     endnum : Integer; //腟?????????合??/span>
664     buf : String;
665     ret : Boolean;
666     begin
667     ret := true;
668     datstl := TStringList.Create;
669     try
670     try
671     datstl.LoadFromFile(datfilepath);
672     if (firstres > 0) and (firstres <= datstl.Count) then begin
673     if firstres + count -1 > datstl.Count then begin
674     endnum := datstl.Count;
675     end else if count <= 0 then begin
676     endnum := firstres + 1;
677     end else begin
678     endnum := firstres + count -1;
679     end;
680     for i := firstres to endnum do begin
681     if AnsiPos(FAbonString, datstl.Strings[i-1]) = 1 then begin
682     buf := datstl.Strings[i-1];
683     Delete(buf,1,Length(FAbonString));
684     datstl.Strings[i-1] := buf;
685     end;
686     end;
687     end;
688     datstl.SaveToFile(datfilepath);
689     except
690     ret := false;
691     end;
692     finally
693     datstl.Free;
694     end;
695     Result := ret;
696     end;
697     //?????祉??絅眼??=================?????障??========================================
698     //?上???祉??????????????NGword.txt??????span>
699     procedure TAbon.EditNGwords();
700     begin
701     ShellExecute(0 ,nil,PChar(FNGwordpath),nil,nil,SW_SHOW);
702     end;
703 h677 1.12 //???????≪???????ゅ??∽??/span>
704 h677 1.3 function TAbon.CheckAbonPopupRes(line : String) :Boolean;
705 h677 1.9 begin
706     if AbonPopupRes = true then begin
707     Result := FindNGwords(line);
708     end else begin
709     Result := false;
710     end;
711     end;
712 h677 1.10 //茲??違??G???若???????鴻????茯??粋昭??==============================================
713 h677 1.9 //List???<?ゃ????茯??粋昭??
714     function TAbon.LoadListFile(path :String; listStringList : TStringList) : Boolean;
715     begin
716     try
717     listStringList.LoadFromFile(path);
718     Result := true;
719     except
720     listStringList.Append('筝???NGword.txt');
721     listStringList.SaveToFile(path);
722     Result := false;
723     end;
724     end;
725     //List????ゆ???G???若?????<?ゃ????茯??粋昭??
726     function TAbon.GoForward() : Boolean;
727 h677 1.10 begin
728     FNGwordFileIndex := FNGwordFileIndex + 1;
729     Result := ReadNGwordslist(FNGwordFileIndex);
730     end;
731     //List????ゅ????G???若?????<?ゃ????茯??粋昭??
732     function TAbon.GoBack() : Boolean;
733     begin
734     FNGwordFileIndex := FNGwordFileIndex -1;
735     Result := ReadNGwordslist(FNGwordFileIndex);
736     end;
737     //List???茵?????茯???
738     procedure TAbon.GoHome();
739     begin
740     FNGwordFileIndex := 0;
741     ReadNGwordslist(FNGwordFileIndex);
742     end;
743     //List??ine茵?????茯???
744     function TAbon.ReadNGwordslist(line : Integer) : Boolean;
745 h677 1.3 var
746 h677 1.9 liststl : TStringList;
747     linebuf : String;
748 h677 1.3 begin
749 h677 1.9 liststl := TStringList.Create;
750     try
751     if LoadListFile(Flistpath,liststl) = true then begin
752 h677 1.10 if line < 0 then begin
753     line := liststl.Count - 1;
754     FNGwordFileIndex := liststl.Count - 1;
755     end else if line > liststl.Count - 1 then begin
756     line := 0;
757 h677 1.9 FNGwordFileIndex := 0;
758     end;
759 h677 1.10 linebuf := liststl.Strings[line];
760 h677 1.9 FNGwordname := Copy(linebuf,1,AnsiPos('=',linebuf)-1);
761     Delete(linebuf,1,AnsiPos('=',linebuf));
762     SetNGwordpath(linebuf);
763     Result := true;
764 h677 1.3 end else begin
765     Result := false;
766 h677 1.9 end
767     finally
768     liststl.Free;
769 h677 1.3 end;
770 h677 1.9
771     end;
772 h677 1.10 //茲??違??G???若???????鴻????茯??粋昭??=====?????障??================================
773 h677 1.11 //???ャ???若????絎?茵??∽??/span>
774     procedure TAbon.IndividualAbon(var ThreadStrings : TStringList; SetResNumFile : String);
775     var
776     i : Integer;
777     begin
778     if FileExists(SetResNumFile) = true then begin
779     if LoadFromSetResNumFile(SetResNumFile) = true then begin
780     for i := 0 to High(FAbonRes) do begin
781     if (FAbonRes[i].Res <= ThreadStrings.Count) and (FAbonRes[i].Res > 0) then begin
782     if FAbonRes[i].option = 0 then begin
783     ThreadStrings.Strings[FAbonRes[i].Res-1] := '';
784     end else begin
785 hi_ 1.13 ThreadStrings.Strings[FAbonRes[i].Res-1] := '???若????<>???若????<>???若????<>???若????<>';
786 h677 1.11 end;
787     end;
788    
789     end;
790     end;
791     end else begin
792     FIndividualFileName := SetResNumFile;
793     SetLength(FAbonRes,1);
794     FAbonRes[0].Res := 0;
795     FAbonRes[0].option := -1;
796     end;
797     end;
798     //???ャ???若???????<?ゃ????粋昭?翠?∽??/span>
799     function TAbon.LoadFromSetResNumFile(SetResNumFile : String) : Boolean;
800     var
801     bufStringList : TStringList;
802     bufLine : String;
803     i : Integer;
804     begin
805     bufStringList := TStringList.Create;
806     try
807     try
808     bufStringList.LoadFromFile(SetResNumFile);
809     FIndividualFileName := SetResNumFile;
810     //腥肴?????/span>
811     for i := bufStringList.Count-1 downto 0 do begin
812     if bufStringList.Strings[i] = '' then begin
813     bufStringList.Delete(i);
814     end;
815     end;
816    
817     //?<?≪??∈篆?
818     SetLength(FAbonRes,bufStringList.Count);
819     //篁e??/span>
820     for i :=0 to bufStringList.Count - 1 do begin
821     bufLine := Trim(bufStringList.Strings[i]);
822     FAbonRes[i].Res := StrToInt(Copy(bufLine,1,AnsiPos('-',bufLine)-1));
823     FAbonRes[i].option := StrToInt(Copy(bufLine,AnsiPos('-',bufLine)+1,1));
824     end;
825     except
826     Result := false;
827     Exit;
828     end;
829     finally
830     bufStringList.Free;
831     end;
832     Result := true;
833     end;
834     //???ャ???若???????<?ゃ????申??
835     procedure TAbon.AddIndividualAbon( ResNum : Integer ; option : Integer);
836     var
837     IndividualFile : TStringList;
838     linebuf : String;
839     i : Integer;
840     begin
841     IndividualFile := TStringList.Create;
842     if FAbonRes[0].Res <> 0 then begin
843     for i := 0 to High(FAbonRes) do begin
844     if FAbonRes[i].Res <> ResNum then begin
845     linebuf := IntToStr(FAbonRes[i].Res) + '-' + IntToStr(FabonRes[i].option);
846     IndividualFile.Append(linebuf);
847     end;
848     end;
849     end;
850     linebuf := IntToStr(ResNum) + '-' + IntToStr(option);
851     IndividualFile.Append(linebuf);
852     try
853     IndividualFile.SaveToFile(FIndividualFileName);
854     finally
855     IndividualFile.Free;
856     end;
857     end;
858     //???ャ???若???????<?ゃ??????????/span>
859     procedure TAbon.DeleteIndividualAbon( ResNum : Integer);
860     var
861     IndividualFile : TStringList;
862     linebuf : String;
863     i : Integer;
864     begin
865     IndividualFile := TStringList.Create;
866     if FAbonRes[0].Res <> 0 then begin
867     for i := 0 to High(FAbonRes) do begin
868     if FAbonRes[i].Res <> ResNum then begin
869     linebuf := IntToStr(FAbonRes[i].Res) + '-' + IntToStr(FabonRes[i].option);
870     IndividualFile.Append(linebuf);
871     end;
872     end;
873     end;
874     if IndividualFile.Count <> 0 then begin
875     try
876     IndividualFile.SaveToFile(FIndividualFileName);
877     finally
878     IndividualFile.Free;
879     end;
880     end else begin
881     if FileExists(FIndividualFileName) = true then begin
882     DeleteFile(FIndividualFileName);
883     end;
884     end;
885     end;
886     //???ャ???若?????????鴻???????違??菴???
887     function TAbon.GetAbonResCount() : Integer;
888 h677 1.12 var
889     i : Integer;
890 h677 1.11 begin
891 h677 1.12 if FAbonRes[0].Res = 0 then begin
892     Result := 0
893     end else begin
894     i := High(FAbonRes);
895     Result := i+1;
896     end;
897 h677 1.11 end;
898     //???ャ???若?????????鴻?????茵????????鴻????絖????ц???
899     function TAbon.GetAbonResString(Num : Integer) : String;
900     begin
901 h677 1.12 if (Num <= High(FAbonRes)) and (Num >= 0) then begin
902 h677 1.11 Result := IntToStr(FAbonRes[Num].Res);
903     end else begin
904     Result := '';
905     end;
906 h677 1.12 end;
907     //???????≪???????ゅ???/span>
908     function TAbon.CheckIndividualAbonList(ResNum : Integer) : Boolean;
909     var
910     i : Integer;
911     begin
912     if FAbonRes[0].Res <> 0 then begin
913     for i := 0 to High(FAbonRes) do begin
914     if FAbonRes[i].Res = ResNum then begin
915     Result := true;
916     Exit;
917     end;
918     end;
919     end;
920     Result := false;
921    
922 h677 1.11 end;
923 h677 1.1 end.
924    

Back to OSDN">Back to OSDN
ViewVC Help
Powered by ViewVC 1.1.26