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