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.19 - (hide annotations) (download) (as text)
Fri Nov 21 13:50:56 2003 UTC (20 years, 5 months ago) by h677
Branch: MAIN
Changes since 1.18: +91 -63 lines
File MIME type: text/x-pascal
plugin(一行ずつあぼ〜んの処理が必要なやつ)用の関数追加

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

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