Janilabo

Untitled

Aug 16th, 2012
48
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pascal 2.48 KB | None | 0 0
  1. {$DEFINE RSCE}
  2.  
  3. {$I MSSL.scar}
  4.                                                                        
  5. function ReplaceMulti(text: string; findStrArr: TStrArray; replaceStr: string): string;
  6. var
  7.   h, i: Integer;
  8. begin
  9.   Result := text;
  10.   h := High(findStrArr);
  11.   if (h >= 0) then
  12.     for i := 0 to h do
  13.       Result := Replace(Result, findStrArr[i], replaceStr);
  14. end;
  15.  
  16. function ReplaceMultiTSA(TSA, findStrArr: TStrArray; replaceStr: string): TStrArray;
  17. var
  18.   h, h2, i, i2: Integer;
  19. begin
  20.   Result := TSA;
  21.   h := High(findStrArr);
  22.   h2 := High(Result);
  23.   if ((h >= 0) and (h2 >= 0)) then
  24.     for i := 0 to h do
  25.       for i2 := 0 to h2 do
  26.         Result[i2] := Replace(Result[i2], findStrArr[i], replaceStr);
  27. end;
  28.  
  29. function IsUpText(str: string): Boolean;
  30. begin
  31.   Result := (ReplaceMulti(RSCE_UpText([RSCE_UPTEXT_ALL]), ['I', 'l'], ' ') = ReplaceMulti(str, ['I', 'l'], ' '));
  32. end;
  33.  
  34. type
  35.   TTCMethod = (tc_AnyMatch, tc_AllMatch, tc_NonMatch);
  36.  
  37. function TextContains(t: string; TSA: TStrArray; cs: Boolean; m: TTCMethod): Boolean;
  38. var
  39.   h, i: Integer;
  40. begin
  41.   h := High(TSA);
  42.   if ((t = '') or (h < 0)) then
  43.     Exit;
  44.   case m of
  45.     tc_AnyMatch:
  46.       for i := 0 to h do
  47.       begin
  48.         if cs then
  49.           Result := (Pos(TSA[i], t) > 0)
  50.         else
  51.           Result := (Pos(Lowercase(TSA[i]), Lowercase(t)) > 0);
  52.         if Result then
  53.           Exit;
  54.       end;
  55.     tc_AllMatch:        
  56.       begin
  57.         for i := 0 to h do
  58.           case cs of
  59.             True:
  60.               if not (Pos(TSA[i], t) > 0) then
  61.                 Exit;
  62.             False:
  63.               if not (Pos(Lowercase(TSA[i]), Lowercase(t)) > 0) then
  64.                 Exit;
  65.           end;
  66.         Result := True;
  67.       end;
  68.     tc_NonMatch:
  69.       begin
  70.         for i := 0 to h do
  71.           case cs of
  72.             True:
  73.               if (Pos(TSA[i], t) > 0) then
  74.                 Exit;
  75.             False:
  76.               if (Pos(Lowercase(TSA[i]), Lowercase(t)) > 0) then
  77.                 Exit;
  78.           end;
  79.         Result := True;
  80.       end;    
  81.   end;
  82. end;  
  83.  
  84. var
  85.   uptext: string;
  86.   objs: TStrArray;
  87.  
  88. begin
  89.   MSSL_Setup;
  90.   RSCE_Client.Activate;
  91.   Wait(2500);    
  92.   uptext := ReplaceMulti(RSCE_UpText([RSCE_UPTEXT_NPC]), ['I', 'l'], '*');
  93.   WriteLn('UPTEXT: ' + uptext);
  94.   objs := ReplaceMultiTSA(['Banker', 'Master Fisher', 'Man', 'Goblin'], ['I', 'l'], '*');
  95.   if TextContains(uptext, objs, True, tc_AnyMatch) then
  96.     WriteLn('WOOHOOO');
  97.   MSSL_Unsetup;
  98. end.
Advertisement
Add Comment
Please, Sign In to add comment