Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const
- BUGGY_STYLE = False;
- {==============================================================================]
- Explanation: Replaces all findStrArr items in TSA with replaceStr. - BUGGY?!
- [==============================================================================}
- function TSAReplaceMultiA(TSA, findStrArr: TStrArray; replaceStr: string): TStrArray;
- var
- h, h2, i, i2: Integer;
- begin
- h := High(findStrArr);
- h2 := High(TSA);
- SetLength(Result, (h2 + 1));
- if ((h >= 0) and (h2 >= 0)) then
- for i := 0 to h do
- for i2 := 0 to h2 do
- Result[i2] := Replace(TSA[i2], findStrArr[i], replaceStr);
- end;
- {==============================================================================]
- Explanation: Replaces all findStrArr items in TSA with replaceStr. WORKS...
- [==============================================================================}
- function TSAReplaceMultiB(TSA, findStrArr: TStrArray; replaceStr: string): TStrArray;
- var
- h, h2, i, i2: Integer;
- begin
- h := High(findStrArr);
- h2 := High(TSA);
- Result := TSA;
- if ((h >= 0) and (h2 >= 0)) then
- for i := 0 to h do
- for i2 := 0 to h2 do
- Result[i2] := Replace(Result[i2], findStrArr[i], replaceStr);
- end;
- var
- h, i: Integer;
- a, b: TStrArray;
- begin
- a := ['Test1', 'Test2', 'Test3', 'Test4'];
- b := a;
- SetLength(a, 0);
- h := High(b);
- case BUGGY_STYLE of
- True: b := TSAReplaceMultiA(b, ['Test'], 'Item');
- False: b := TSAReplaceMultiB(b, ['Test'], 'Item');
- end;
- for i := 0 to h do
- WriteLn(b[i]);
- SetLength(b, 0);
- end.
Advertisement
Add Comment
Please, Sign In to add comment