Changeset 50 for trunk/UAcronym.pas
- Timestamp:
- Jul 25, 2016, 5:07:25 PM (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/UAcronym.pas
r47 r50 115 115 end; 116 116 117 TImportPatternFlag = (ipfNone, ipfNewItem, ipfSkip );117 TImportPatternFlag = (ipfNone, ipfNewItem, ipfSkip, ipfRemove); 118 118 TImportVariable = (ivNone, ivAcronym, ivMeaning, ivDescription); 119 119 … … 247 247 SNewItem = 'New item'; 248 248 SSkip = 'Skip'; 249 SRemoveOnStart = 'Remove on start'; 250 SUnsupportedAuthMethod = 'Unsupported HTTP authorization method'; 249 251 250 252 … … 258 260 ImportPatternFlagString[ipfNewItem] := SNewItem; 259 261 ImportPatternFlagString[ipfSkip] := SSkip; 262 ImportPatternFlagString[ipfRemove] := SRemoveOnStart; 260 263 end; 261 264 … … 393 396 var 394 397 H: string; 395 P: Integer;396 398 begin 397 399 with TFPHttpClient(Sender) do begin … … 400 402 401 403 if H <> 'Basic' then 402 raise Exception.Create( 'Unsupported HTTP authorization method');404 raise Exception.Create(SUnsupportedAuthMethod); 403 405 404 406 if (Self.UserName <> '') and (UserName = '') then begin … … 440 442 441 443 // Remove unneeded items 442 {repeat444 repeat 443 445 LastLength := Length(S); 444 446 for I := 0 to Format.ItemPatterns.Count - 1 do 445 447 with TImportPattern(Format.ItemPatterns[I]) do 446 if Flag = ipf Skipthen begin448 if Flag = ipfRemove then begin 447 449 P := Pos(StartString, S); 448 450 if P > 0 then begin … … 455 457 end; 456 458 until Length(S) = LastLength; 457 } 459 458 460 // Find items 459 461 repeat … … 462 464 while I < Format.ItemPatterns.Count do 463 465 with TImportPattern(Format.ItemPatterns[I]) do begin 464 if Flag <> ipf Skipthen begin466 if Flag <> ipfRemove then begin 465 467 if Length(StartString) > 0 then begin 466 468 P := Pos(StartString, S); … … 470 472 if ((Length(StartString) > 0) and (P > 0)) or (Length(StartString) = 0) then begin 471 473 P := Pos(EndString, S); 472 T := StripHTML(Copy(S, 1, P - 1)); 473 T := StringReplace(T, '"', '"', [rfReplaceAll]); 474 T := StringReplace(T, '™', 'TM', [rfReplaceAll]); 475 T := StringReplace(T, '&', '&', [rfReplaceAll]); 476 T := StringReplace(T, ' ', ' ', [rfReplaceAll]); // No break space 477 T := Trim(T); 478 case Variable of 479 ivAcronym: NewAcronym.Name := T; 480 ivMeaning: NewAcronym.Meaning := T; 481 ivDescription: NewAcronym.Description := T; 474 T := Copy(S, 1, P - 1); 475 if Flag <> ipfSkip then begin 476 T := StripHTML(T); 477 T := StringReplace(T, '"', '"', [rfReplaceAll]); 478 T := StringReplace(T, '™', 'TM', [rfReplaceAll]); 479 T := StringReplace(T, '&', '&', [rfReplaceAll]); 480 T := StringReplace(T, ' ', ' ', [rfReplaceAll]); // No break space 481 T := Trim(T); 482 case Variable of 483 ivAcronym: NewAcronym.Name := T; 484 ivMeaning: NewAcronym.Meaning := T; 485 ivDescription: NewAcronym.Description := T; 486 end; 482 487 end; 483 488 Delete(S, 1, P + Length(EndString) - 1);
Note:
See TracChangeset
for help on using the changeset viewer.