| 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 |
FDeleterlo : Boolean; //&rlo;???????? //菴遵??&lro;?????? |
| 23 |
FReplaceul :Boolean ; //<ul>?帥?違??<br>?帥?違??舟???????? |
| 24 |
FReverse : Boolean ; //NG???若???с?????若?????????????荵≪???????? |
| 25 |
FAbonPopupRes : Boolean; //???鴻???????≪?????????????若?若???????? |
| 26 |
FNGwordFileIndex : Integer; //?上????粋昭???с??NG???若????list???茵????? |
| 27 |
FNGwordname : String; //?上????粋昭???с??NG???若????;腓阪?? |
| 28 |
FIndividualFileName : String; //???ャ???若?????????<?ゃ???? |
| 29 |
FReturnNGwordLineNum : Boolean; //NG???若??????違??菴????? |
| 30 |
FSetNGResAnchor : Boolean; //NG???綵????????????????????????鴻?吾?????鴻?≪?潟???若???ゃ???????????? |
| 31 |
FDeleteSyria: Boolean; //?激???∵??????????膈?鐚?܀~ݏ鐚? |
| 32 |
procedure SetTokens(index: integer ; argline:String); |
| 33 |
function Getlistpath() : String; |
| 34 |
procedure Setlistpath(const Value : String); |
| 35 |
function LoadListFile(path :String;listStringList : TStringList) : Boolean; |
| 36 |
function ReadNGwordslist(line : Integer) : Boolean; |
| 37 |
function LoadFromSetResNumFile(SetResNumFile : String) : Boolean; |
| 38 |
public |
| 39 |
{ Public 絎h? } |
| 40 |
constructor Create; // ?潟?潟?鴻????????/span> |
| 41 |
destructor Destroy; override; // ???鴻????????/span> |
| 42 |
property Deleterlo: Boolean read FDeleterlo write FDeleterlo default false; |
| 43 |
property Replaceul: Boolean read FReplaceul write FReplaceul default false; |
| 44 |
property Reverse: Boolean read FReverse write FReverse default false; |
| 45 |
property AbonString : String read FAbonString write FAbonString; |
| 46 |
property AbonPopupRes : Boolean read FAbonPopupRes write FAbonPopupRes default false; |
| 47 |
property listpath : String read Getlistpath write Setlistpath; |
| 48 |
property NGwordFileIndex : Integer read FNGwordFileIndex write FNGwordFileIndex default 0; |
| 49 |
property NGwordname : String read FNGwordname write FNGwordname; |
| 50 |
property ReturnNGwordLineNum : Boolean read FReturnNGwordLineNum write FReturnNGwordLineNum default false; |
| 51 |
property SetNGResAnchor : Boolean read FSetNGResAnchor write FSetNGResAnchor default false; |
| 52 |
property DeleteSyria : Boolean read FDeleteSyria write FDeleteSyria default false; |
| 53 |
procedure Setroot(root :String); |
| 54 |
function Getroot() : String; |
| 55 |
|
| 56 |
function Getfullpath(argpath : String) : String; |
| 57 |
procedure SetNGwordpath(path :String); |
| 58 |
function GetNGwordpath() : String; |
| 59 |
function LoadFromNGwordFile(path :String) : Boolean; |
| 60 |
function ReLoadFromNGwordFile() : Boolean; |
| 61 |
procedure LoadFromStringList( bufstl : TStringList ); |
| 62 |
function CheckAbonPopupRes(line : String) :Boolean; |
| 63 |
function FindNGwords(const line : String; var NGwordsLineNum : Integer; var Invisible : Boolean) : Boolean;//1???ゃ?潟???ょ???? |
| 64 |
//???若????????(NG???若???с?????c???帥???潟?? |
| 65 |
procedure Execute(var ThreadStrings : TStringList); overload; |
| 66 |
procedure Execute(var ResString : String; ResNumber : Integer); overload; //筝祉??lugin??????at To HTML ??/span> |
| 67 |
|
| 68 |
//???ャ???若?????????? |
| 69 |
procedure IndividualAbon(var ThreadStrings : TStringList; SetResNumFile : String); overload; |
| 70 |
procedure IndividualAbon(var ResString : String; SetResNumFile : String; ResNumber : Integer); overload; |
| 71 |
procedure AddIndividualAbon( ResNum : Integer ; option : Integer; SetResNumFile : String); |
| 72 |
function CheckIndividualAbonList(ResNum : Integer) : Boolean; |
| 73 |
|
| 74 |
procedure EditNGwords(); //NGword.txt??????? |
| 75 |
function ShowAllTokens() : String; //???????亥??/span> |
| 76 |
//-- |
| 77 |
procedure GoHome();//List???茵?????茯??? |
| 78 |
function GoForward() : Boolean; //List????ゆ???G???若?????<?ゃ????茯??粋昭?? |
| 79 |
function GoBack() : Boolean; //List????ゅ????G???若?????<?ゃ????茯??粋昭?? |
| 80 |
//-- |
| 81 |
function TreatSyria(AString: string): string; |
| 82 |
end; |
| 83 |
var |
| 84 |
Abon1 :TAbon; |
| 85 |
const |
| 86 |
NGwordListFileName : String = 'NGwords.list'; |
| 87 |
|
| 88 |
implementation |
| 89 |
|
| 90 |
uses MojuUtils; |
| 91 |
|
| 92 |
constructor TAbon.Create; |
| 93 |
begin |
| 94 |
// ?????? |
| 95 |
FAbonString := ' <> <> <> <><>'; |
| 96 |
SetLength(FAbonRes,1); |
| 97 |
FAbonRes[0].Res := 0; |
| 98 |
FAbonRes[0].option := -1; |
| 99 |
|
| 100 |
end; |
| 101 |
|
| 102 |
destructor TAbon.Destroy; |
| 103 |
begin |
| 104 |
inherited; |
| 105 |
end; |
| 106 |
//root??xe\config\NGwords???????? |
| 107 |
procedure TAbon.Setroot(root :String); |
| 108 |
var |
| 109 |
bufStringList : TStringList; |
| 110 |
begin |
| 111 |
bufStringList := TStringList.Create; |
| 112 |
try |
| 113 |
if not DirectoryExists(root) then begin |
| 114 |
CreateDir(root); |
| 115 |
end; |
| 116 |
if root[Length(root)] <> '\' then begin |
| 117 |
root := root + '\'; |
| 118 |
end; |
| 119 |
Flistpath := root + NGwordListFileName; |
| 120 |
LoadListFile(Flistpath, bufStringList); |
| 121 |
finally |
| 122 |
bufStringList.Free; |
| 123 |
end; |
| 124 |
Froot := root; |
| 125 |
end; |
| 126 |
function TAbon.Getroot() : String; |
| 127 |
begin |
| 128 |
Result := Froot; |
| 129 |
end; |
| 130 |
//NGwordpath??Gword.txt??????????/span> |
| 131 |
procedure TAbon.SetNGwordpath(path :String); |
| 132 |
begin |
| 133 |
FNGwordpath := Getfullpath(path); |
| 134 |
LoadFromNGwordFile(FNGwordpath); |
| 135 |
end; |
| 136 |
function TAbon.GetNGwordpath() : String; |
| 137 |
begin |
| 138 |
Result := FNGwordpath; |
| 139 |
end; |
| 140 |
//???????鴻?с???????違???????鴻??????????? |
| 141 |
function TAbon.Getfullpath(argpath : String) : String; |
| 142 |
begin |
| 143 |
if AnsiPos(':\',argpath) <> 2 then begin //?????ゃ???????????????鴻???<??????/span> |
| 144 |
if Getroot() = '' then begin |
| 145 |
Result := ''; //root???鴻??荐??????????????腥冴?????? |
| 146 |
end else begin |
| 147 |
if (Froot[Length(Froot)] = '\') and (argpath[1] = '\') then begin //????????????/span> |
| 148 |
Delete(argpath,1,1); |
| 149 |
end; |
| 150 |
Insert( Getroot(), argpath , 1);//root???鴻???水??/span> |
| 151 |
Result := argpath; |
| 152 |
end; |
| 153 |
end else begin |
| 154 |
Result := argpath; |
| 155 |
end; |
| 156 |
|
| 157 |
end; |
| 158 |
//NGword???<?ゃ??????粋昭??/span> |
| 159 |
function TAbon.LoadFromNGwordFile(path :String) : boolean; |
| 160 |
var |
| 161 |
bufstl : TStringList; |
| 162 |
begin |
| 163 |
path := Getfullpath(path); |
| 164 |
if path = '' then begin |
| 165 |
Result := false; |
| 166 |
end else begin |
| 167 |
|
| 168 |
bufstl := TStringList.Create; |
| 169 |
try |
| 170 |
if not FileExists(path) then begin |
| 171 |
Result := false; |
| 172 |
try |
| 173 |
bufstl.SaveToFile(path); |
| 174 |
except |
| 175 |
end; |
| 176 |
end else begin |
| 177 |
bufstl.LoadFromFile(path); |
| 178 |
LoadFromStringList( bufstl ); |
| 179 |
Result := true; |
| 180 |
end; |
| 181 |
finally |
| 182 |
bufstl.Free; |
| 183 |
end; |
| 184 |
end; |
| 185 |
|
| 186 |
end; |
| 187 |
//NGword???鴻??茯??粋昭??/span> |
| 188 |
procedure TAbon.LoadFromStringList( bufstl : TStringList ); |
| 189 |
var |
| 190 |
i : integer; |
| 191 |
begin |
| 192 |
try |
| 193 |
for i := bufstl.Count -1 downto 0 do begin |
| 194 |
if bufstl.Strings[i] = '' then begin |
| 195 |
bufstl.Delete(i); |
| 196 |
end; |
| 197 |
end; |
| 198 |
SetLength(Ftokens,bufstl.Count); |
| 199 |
for i := 0 to bufstl.Count -1 do begin |
| 200 |
SetTokens(i , bufstl.Strings[i]); |
| 201 |
end; |
| 202 |
|
| 203 |
except |
| 204 |
Exit; |
| 205 |
end; |
| 206 |
end; |
| 207 |
//NGwordpath???≪??┃絎??????????????????????若?????∽??/span> |
| 208 |
function TAbon.ReLoadFromNGwordFile() : boolean; |
| 209 |
begin |
| 210 |
if GetNGwordpath() ='' then begin |
| 211 |
Result := false; |
| 212 |
end else begin |
| 213 |
Result := LoadFromNGwordFile( GetNGwordpath() ); |
| 214 |
end; |
| 215 |
end; |
| 216 |
function TAbon.Getlistpath() : String; |
| 217 |
begin |
| 218 |
Result := Flistpath; |
| 219 |
end; |
| 220 |
procedure TAbon.Setlistpath(const Value : String); |
| 221 |
begin |
| 222 |
Flistpath := Getfullpath(Value); |
| 223 |
end; |
| 224 |
//筝?茵???賢?????若???潟?????????????祉???? |
| 225 |
procedure TAbon.SetTokens(index: integer ; argline : String); |
| 226 |
var |
| 227 |
ret : Integer; |
| 228 |
bufstl : TStringList; |
| 229 |
i : Integer; |
| 230 |
pos : Integer; |
| 231 |
buftoken : String; |
| 232 |
begin |
| 233 |
pos := 0; |
| 234 |
bufstl := TStringList.Create; |
| 235 |
try |
| 236 |
if Length(argline) > 0 then begin |
| 237 |
pos := AnsiPos(#9,argline); |
| 238 |
while pos <> 0 DO begin |
| 239 |
buftoken := Copy(argline,1,pos-1); |
| 240 |
Delete(argline,1,pos); |
| 241 |
if Length(buftoken) > 0 then begin |
| 242 |
bufstl.Append(buftoken); |
| 243 |
end else if ( bufstl.Count = 0 ) then begin |
| 244 |
bufstl.Append(''); |
| 245 |
end; |
| 246 |
pos := AnsiPos(#9,argline); |
| 247 |
end; |
| 248 |
if Length(argline) > 0 then begin |
| 249 |
bufstl.Append(argline); |
| 250 |
end; |
| 251 |
ret := bufstl.Count; |
| 252 |
SetLength(Ftokens[index],ret); |
| 253 |
for i := 0 to bufstl.Count - 1 do begin |
| 254 |
Ftokens[index][i] := bufstl.Strings[i]; |
| 255 |
end; |
| 256 |
end; |
| 257 |
finally |
| 258 |
bufstl.Free; |
| 259 |
end; |
| 260 |
|
| 261 |
end; |
| 262 |
//Debug???<??????G???若?????障?????????? |
| 263 |
function TAbon.ShowAllTokens() : String; |
| 264 |
var |
| 265 |
i : Integer; |
| 266 |
j : Integer; |
| 267 |
ret : String; |
| 268 |
begin |
| 269 |
for i := 0 to High(Ftokens) do begin |
| 270 |
for j := 0 to High(Ftokens[i]) do begin |
| 271 |
ret := ret + Ftokens[i][j]; |
| 272 |
end; |
| 273 |
end; |
| 274 |
Result := ret; |
| 275 |
|
| 276 |
|
| 277 |
|
| 278 |
end; |
| 279 |
//NG???若???????障??????????true??菴?????????G???若??????違??NGwordsLineNum???ャ????????? |
| 280 |
//????????????若??????????????Inbisible??true????????? |
| 281 |
function TAbon.FindNGwords(const line : String; var NGwordsLineNum : Integer; var Invisible : Boolean) : Boolean; //1???ゃ?潟???ょ???? |
| 282 |
var |
| 283 |
lines : Integer; |
| 284 |
cells : Integer; |
| 285 |
hit : Boolean; |
| 286 |
bufline : String; |
| 287 |
start : Integer; |
| 288 |
begin |
| 289 |
hit := false; |
| 290 |
if AnsiPos(FAbonString,line) <> 1 then begin |
| 291 |
for lines := 0 to High(Ftokens) do begin |
| 292 |
hit := true; |
| 293 |
bufline := line; |
| 294 |
if Ftokens[lines][0] <> '' then begin |
| 295 |
Invisible := false; |
| 296 |
start := 0; |
| 297 |
end else begin |
| 298 |
Invisible := true; |
| 299 |
start := 1; |
| 300 |
end; |
| 301 |
|
| 302 |
for cells := start 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 |
NGwordsLineNum := lines + 1; |
| 312 |
break; |
| 313 |
end; |
| 314 |
end; |
| 315 |
end; |
| 316 |
Result := hit; |
| 317 |
end; |
| 318 |
//??鮎?????若???ゃ??rue??????NG???若??????????????????菴????? |
| 319 |
procedure TAbon.Execute(var ThreadStrings : TStringList); |
| 320 |
var |
| 321 |
i : Integer; |
| 322 |
NGwordsLine : Integer; |
| 323 |
bufline : String; |
| 324 |
invisi : Boolean; |
| 325 |
begin |
| 326 |
for i:=0 to ThreadStrings.Count - 1 do begin |
| 327 |
NGwordsLine := 0; |
| 328 |
if FindNGwords(ThreadStrings.Strings[i], NGwordsLine ,invisi) <> Reverse then begin |
| 329 |
if invisi = true then begin |
| 330 |
ThreadStrings.Strings[i] := ''; |
| 331 |
end else begin |
| 332 |
if not ReturnNGwordLineNum and not SetNGResAnchor then begin |
| 333 |
ThreadStrings.Strings[i] := FAbonString; |
| 334 |
end else if not ReturnNGwordLineNum then begin |
| 335 |
ThreadStrings.Strings[i] := Format(' <> <> <>>%d<><>',[(i+1)]); |
| 336 |
end else if not SetNGResAnchor then begin |
| 337 |
ThreadStrings.Strings[i] := Format(' <> <> <><B> %d 茵?????G???若???????障???????障????</B><><>',[NGwordsLine]); |
| 338 |
end else begin |
| 339 |
ThreadStrings.Strings[i] := Format(' <> <> <><B> %d 茵?????G???若???????障???????障????</B>>%d <><>',[NGwordsLine,(i+1)]); |
| 340 |
end; |
| 341 |
end; |
| 342 |
end else begin |
| 343 |
bufline := ThreadStrings.Strings[i]; |
| 344 |
if Deleterlo = true then begin |
| 345 |
bufline := CustomStringReplace(bufline,'&rlo;',''); |
| 346 |
bufline := CustomStringReplace(bufline,'&lro;',''); |
| 347 |
end; |
| 348 |
if Replaceul = true then begin |
| 349 |
bufline := CustomStringReplace( bufline,'<ul>','<br>' ); |
| 350 |
bufline := CustomStringReplace( bufline,'</ul>','<br>' ); |
| 351 |
end; |
| 352 |
if DeleteSyria = true then |
| 353 |
bufline := TreatSyria(bufline); |
| 354 |
ThreadStrings.Strings[i] := bufline; |
| 355 |
end; |
| 356 |
end; |
| 357 |
end; |
| 358 |
procedure TAbon.Execute(var ResString : String; ResNumber : Integer); |
| 359 |
var |
| 360 |
NGwordsLine : Integer; |
| 361 |
bufline : String; |
| 362 |
invisi : Boolean; |
| 363 |
begin |
| 364 |
NGwordsLine := 0; |
| 365 |
if FindNGwords(ResString, NGwordsLine ,invisi) <> Reverse then begin |
| 366 |
if invisi = true then begin |
| 367 |
ResString := ''; |
| 368 |
end else begin |
| 369 |
if not ReturnNGwordLineNum and not SetNGResAnchor then begin |
| 370 |
ResString := FAbonString; |
| 371 |
end else if not ReturnNGwordLineNum then begin |
| 372 |
ResString := Format(' <> <> <>>%d<><>',[(ResNumber)]); |
| 373 |
end else if not SetNGResAnchor then begin |
| 374 |
ResString := Format(' <> <> <><B> %d 茵?????G???若???????障???????障????</B><><>',[NGwordsLine]); |
| 375 |
end else begin |
| 376 |
ResString := Format(' <> <> <><B> %d 茵?????G???若???????障???????障????</B>>%d <><>',[NGwordsLine,(ResNumber)]); |
| 377 |
end; |
| 378 |
end; |
| 379 |
end else begin |
| 380 |
bufline := ResString; |
| 381 |
if Deleterlo = true then begin |
| 382 |
bufline := CustomStringReplace( bufline,'&rlo;','' ); |
| 383 |
bufline := CustomStringReplace( bufline,'&lro;','' ); |
| 384 |
end; |
| 385 |
if Replaceul = true then begin |
| 386 |
bufline := CustomStringReplace( bufline,'<ul>','<br>' ); |
| 387 |
bufline := CustomStringReplace( bufline,'</ul>','<br>' ); |
| 388 |
end; |
| 389 |
if DeleteSyria = true then |
| 390 |
bufline := TreatSyria(bufline); |
| 391 |
ResString := bufline; |
| 392 |
end; |
| 393 |
end; |
| 394 |
|
| 395 |
|
| 396 |
|
| 397 |
//****************************************************************************// |
| 398 |
//?上???祉??????????????NGword.txt??????span> |
| 399 |
procedure TAbon.EditNGwords(); |
| 400 |
begin |
| 401 |
ShellExecute(0 ,nil,PChar(FNGwordpath),nil,nil,SW_SHOW); |
| 402 |
end; |
| 403 |
//???????≪???????ゅ??∽??/span> |
| 404 |
function TAbon.CheckAbonPopupRes(line : String) :Boolean; |
| 405 |
var |
| 406 |
i: Integer; |
| 407 |
v: boolean; |
| 408 |
begin |
| 409 |
if AbonPopupRes = true then begin |
| 410 |
Result := FindNGwords(line, i ,v); |
| 411 |
end else begin |
| 412 |
Result := false; |
| 413 |
end; |
| 414 |
end; |
| 415 |
//茲??違??G???若???????鴻????茯??粋昭??============================================== |
| 416 |
//List???<?ゃ????茯??粋昭?? |
| 417 |
function TAbon.LoadListFile(path :String; listStringList : TStringList) : Boolean; |
| 418 |
begin |
| 419 |
try |
| 420 |
listStringList.LoadFromFile(path); |
| 421 |
Result := true; |
| 422 |
except |
| 423 |
listStringList.Append('筝???NGword.txt'); |
| 424 |
listStringList.SaveToFile(path); |
| 425 |
Result := false; |
| 426 |
end; |
| 427 |
end; |
| 428 |
//List????ゆ???G???若?????<?ゃ????茯??粋昭?? |
| 429 |
function TAbon.GoForward() : Boolean; |
| 430 |
begin |
| 431 |
FNGwordFileIndex := FNGwordFileIndex + 1; |
| 432 |
Result := ReadNGwordslist(FNGwordFileIndex); |
| 433 |
end; |
| 434 |
//List????ゅ????G???若?????<?ゃ????茯??粋昭?? |
| 435 |
function TAbon.GoBack() : Boolean; |
| 436 |
begin |
| 437 |
FNGwordFileIndex := FNGwordFileIndex -1; |
| 438 |
Result := ReadNGwordslist(FNGwordFileIndex); |
| 439 |
end; |
| 440 |
//List???茵?????茯??? |
| 441 |
procedure TAbon.GoHome(); |
| 442 |
begin |
| 443 |
FNGwordFileIndex := 0; |
| 444 |
ReadNGwordslist(FNGwordFileIndex); |
| 445 |
end; |
| 446 |
//List??ine茵?????茯??? |
| 447 |
function TAbon.ReadNGwordslist(line : Integer) : Boolean; |
| 448 |
var |
| 449 |
liststl : TStringList; |
| 450 |
linebuf : String; |
| 451 |
begin |
| 452 |
liststl := TStringList.Create; |
| 453 |
try |
| 454 |
if LoadListFile(Flistpath,liststl) = true then begin |
| 455 |
if line < 0 then begin |
| 456 |
line := liststl.Count - 1; |
| 457 |
FNGwordFileIndex := liststl.Count - 1; |
| 458 |
end else if line > liststl.Count - 1 then begin |
| 459 |
line := 0; |
| 460 |
FNGwordFileIndex := 0; |
| 461 |
end; |
| 462 |
linebuf := liststl.Strings[line]; |
| 463 |
FNGwordname := Copy(linebuf,1,AnsiPos('=',linebuf)-1); |
| 464 |
Delete(linebuf,1,AnsiPos('=',linebuf)); |
| 465 |
SetNGwordpath(linebuf); |
| 466 |
Result := true; |
| 467 |
end else begin |
| 468 |
Result := false; |
| 469 |
end |
| 470 |
finally |
| 471 |
liststl.Free; |
| 472 |
end; |
| 473 |
|
| 474 |
end; |
| 475 |
//茲??違??G???若???????鴻????茯??粋昭??=====?????障??================================ |
| 476 |
//???ャ???若????絎?茵??∽??/span> |
| 477 |
procedure TAbon.IndividualAbon(var ThreadStrings : TStringList; SetResNumFile : String); |
| 478 |
var |
| 479 |
i : Integer; |
| 480 |
begin |
| 481 |
if FileExists(SetResNumFile) = true then begin |
| 482 |
if LoadFromSetResNumFile(SetResNumFile) = true then begin |
| 483 |
for i := 0 to High(FAbonRes) do begin |
| 484 |
if (FAbonRes[i].Res <= ThreadStrings.Count) and (FAbonRes[i].Res > 0) then begin |
| 485 |
if FAbonRes[i].option = 0 then begin |
| 486 |
ThreadStrings.Strings[FAbonRes[i].Res-1] := ''; |
| 487 |
end else begin |
| 488 |
ThreadStrings.Strings[FAbonRes[i].Res-1] := '???若????<>???若????<>???若????<>???若????<>'; |
| 489 |
end; |
| 490 |
end; |
| 491 |
|
| 492 |
end; |
| 493 |
end; |
| 494 |
end else begin |
| 495 |
FIndividualFileName := SetResNumFile; |
| 496 |
SetLength(FAbonRes,1); |
| 497 |
FAbonRes[0].Res := 0; |
| 498 |
FAbonRes[0].option := -1; |
| 499 |
end; |
| 500 |
end; |
| 501 |
procedure TAbon.IndividualAbon(var ResString : String; SetResNumFile : String; ResNumber : Integer); |
| 502 |
var |
| 503 |
i : Integer; |
| 504 |
begin |
| 505 |
if FileExists(SetResNumFile) = true then begin |
| 506 |
if LoadFromSetResNumFile(SetResNumFile) = true then begin |
| 507 |
for i := 0 to High(FAbonRes) do begin |
| 508 |
if FAbonRes[i].Res = ResNumber then begin |
| 509 |
if FAbonRes[i].option = 0 then begin |
| 510 |
ResString := ''; |
| 511 |
end else begin |
| 512 |
ResString := '???若????<>???若????<>???若????<>???若????<>'; |
| 513 |
end; |
| 514 |
Exit; |
| 515 |
end; |
| 516 |
end; |
| 517 |
end; |
| 518 |
end else begin |
| 519 |
FIndividualFileName := SetResNumFile; |
| 520 |
SetLength(FAbonRes,1); |
| 521 |
FAbonRes[0].Res := 0; |
| 522 |
FAbonRes[0].option := -1; |
| 523 |
end; |
| 524 |
end; |
| 525 |
|
| 526 |
//???ャ???若???????<?ゃ????粋昭?翠?∽??/span> |
| 527 |
function TAbon.LoadFromSetResNumFile(SetResNumFile : String) : Boolean; |
| 528 |
var |
| 529 |
bufStringList : TStringList; |
| 530 |
bufLine : String; |
| 531 |
i : Integer; |
| 532 |
begin |
| 533 |
bufStringList := TStringList.Create; |
| 534 |
try |
| 535 |
try |
| 536 |
bufStringList.LoadFromFile(SetResNumFile); |
| 537 |
FIndividualFileName := SetResNumFile; |
| 538 |
//腥肴?????/span> |
| 539 |
for i := bufStringList.Count-1 downto 0 do begin |
| 540 |
if bufStringList.Strings[i] = '' then begin |
| 541 |
bufStringList.Delete(i); |
| 542 |
end; |
| 543 |
end; |
| 544 |
|
| 545 |
//?<?≪??∈篆? |
| 546 |
SetLength(FAbonRes,bufStringList.Count); |
| 547 |
//篁e??/span> |
| 548 |
for i :=0 to bufStringList.Count - 1 do begin |
| 549 |
bufLine := Trim(bufStringList.Strings[i]); |
| 550 |
FAbonRes[i].Res := StrToInt(Copy(bufLine,1,AnsiPos('-',bufLine)-1)); |
| 551 |
FAbonRes[i].option := StrToInt(Copy(bufLine,AnsiPos('-',bufLine)+1,1)); |
| 552 |
end; |
| 553 |
except |
| 554 |
Result := false; |
| 555 |
Exit; |
| 556 |
end; |
| 557 |
finally |
| 558 |
bufStringList.Free; |
| 559 |
end; |
| 560 |
Result := true; |
| 561 |
end; |
| 562 |
//???ャ???若???????<?ゃ????申?? |
| 563 |
procedure TAbon.AddIndividualAbon( ResNum : Integer ; option : Integer; SetResNumFile : String); |
| 564 |
var |
| 565 |
IndividualFile : TStringList; |
| 566 |
i, j : Integer; |
| 567 |
begin |
| 568 |
IndividualFile := TStringList.Create; |
| 569 |
try |
| 570 |
if FileExists(SetResNumFile) then begin |
| 571 |
IndividualFile.LoadFromFile(SetResNumFile); |
| 572 |
i := -1; |
| 573 |
for j := 0 to IndividualFile.Count -1 do begin |
| 574 |
if AnsiPos(IntToStr(ResNum) + '-', IndividualFile[j]) = 1 then begin |
| 575 |
i := j; |
| 576 |
break; |
| 577 |
end; |
| 578 |
end; |
| 579 |
if i = -1 then |
| 580 |
IndividualFile.Add(IntToStr(ResNum) + '-' + IntToStr(option)) |
| 581 |
else |
| 582 |
IndividualFile[j] := IntToStr(ResNum) + '-' + IntToStr(option); |
| 583 |
|
| 584 |
end else begin |
| 585 |
IndividualFile.Add(IntToStr(ResNum) + '-' + IntToStr(option)); |
| 586 |
end; |
| 587 |
IndividualFile.SaveToFile(SetResNumFile); |
| 588 |
finally |
| 589 |
IndividualFile.Free; |
| 590 |
end; |
| 591 |
end; |
| 592 |
|
| 593 |
//???????≪???????ゅ???/span> |
| 594 |
function TAbon.CheckIndividualAbonList(ResNum : Integer) : Boolean; |
| 595 |
var |
| 596 |
i : Integer; |
| 597 |
begin |
| 598 |
if FAbonRes[0].Res <> 0 then begin |
| 599 |
for i := 0 to High(FAbonRes) do begin |
| 600 |
if FAbonRes[i].Res = ResNum then begin |
| 601 |
Result := true; |
| 602 |
Exit; |
| 603 |
end; |
| 604 |
end; |
| 605 |
end; |
| 606 |
Result := false; |
| 607 |
|
| 608 |
end; |
| 609 |
//?激???∵??????????膈? |
| 610 |
function TAbon.TreatSyria(AString: string): string; |
| 611 |
var |
| 612 |
//count: Integer; //(܀~ݏ) |
| 613 |
pos: Integer; |
| 614 |
tmp: string; |
| 615 |
begin |
| 616 |
pos := AnsiPos('', AString); |
| 617 |
while pos <> 0 do begin |
| 618 |
if StrToIntDef(Copy(AString, pos+4, 2), -1) > 0 then begin |
| 619 |
if (AString[pos+6] = ';' ) or (AString[pos+6] = ' ') then begin |
| 620 |
tmp := tmp + Copy(AString, 1, pos - 1); |
| 621 |
Delete(AString, 1, pos+6); |
| 622 |
end else if StrToIntDef(AString[pos+6], -1) = -1 then begin |
| 623 |
tmp := tmp + Copy(AString, 1, pos - 1); |
| 624 |
Delete(AString, 1, pos+5); |
| 625 |
end else begin |
| 626 |
tmp := tmp + Copy(AString, 1, pos + 5); |
| 627 |
Delete(AString, 1, pos+5); |
| 628 |
end; |
| 629 |
end else begin |
| 630 |
tmp := tmp + Copy(AString, 1, pos + 5); |
| 631 |
Delete(AString, 1, pos+5); |
| 632 |
end; |
| 633 |
pos := AnsiPos('', AString); |
| 634 |
end; |
| 635 |
if Length(AString) > 0 then |
| 636 |
tmp := tmp + AString; |
| 637 |
AString := tmp; |
| 638 |
tmp := ''; |
| 639 |
|
| 640 |
pos := AnsiPos('³', AString); |
| 641 |
while pos <> 0 do begin |
| 642 |
if StrToIntDef(Copy(AString, pos+5, 1), 0) > 2 then begin |
| 643 |
if (AString[pos+6] = ';') or (AString[pos+6] = ' ') then begin |
| 644 |
tmp := tmp + Copy(AString, 1, pos - 1); |
| 645 |
Delete(AString, 1, pos+6); |
| 646 |
end else if StrToIntDef(AString[pos+6], -1) = -1 then begin |
| 647 |
tmp := tmp + Copy(AString, 1, pos - 1); |
| 648 |
Delete(AString, 1, pos+5); |
| 649 |
end else begin |
| 650 |
tmp := tmp + Copy(AString, 1, pos + 5); |
| 651 |
Delete(AString, 1, pos+5); |
| 652 |
end; |
| 653 |
end else begin |
| 654 |
tmp := tmp + Copy(AString, 1, pos + 5); |
| 655 |
Delete(AString, 1, pos+5); |
| 656 |
end; |
| 657 |
pos := AnsiPos('³', AString); |
| 658 |
end; |
| 659 |
if Length(AString) > 0 then |
| 660 |
tmp := tmp + AString; |
| 661 |
Result := tmp; |
| 662 |
end; |
| 663 |
|
| 664 |
|
| 665 |
|
| 666 |
end. |
| 667 |
|