Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function Explode2(separator, str: string): TStringArray;
- var
- a, b, l, p, r, s: Integer;
- m: Boolean;
- begin;
- SetLength(Result, 1);
- l := Length(str);
- if (l > 0) then
- begin
- s := Length(separator);
- a := 1;
- p := 1;
- r := 0;
- while ((a + (s - 1)) <= l) do
- begin
- for b := 1 to s do
- begin
- m := (str[((a + b) - 1)] = separator[b]);
- if not m then
- Break;
- end;
- if m then
- begin
- Result[r] := Copy(str, p, (a - p));
- p := (a + s);
- a := ((a + s) - 1);
- if (a = l) then
- Exit;
- Inc(r);
- SetLength(result, (r + 1));
- end;
- Inc(a);
- end;
- Result[r] := Copy(str, p, ((l - p) + 1));
- end else
- Result[0] := '';
- end;
- var
- s: string;
- x: Integer;
- a, b: TStringArray;
- begin
- ClearDebug;
- x := OpenFile(ScriptPath + 'ClearTPAFromTPA2.simba', False);
- ReadFileString(x, s, FileSize(x));
- CloseFile(x);
- s := (s + ' ! a');
- a := Explode(' ', s);
- WriteLn(ToStr(a[High(a)]));
- WriteLn(ToStr(Length(a)));
- b := Explode2(' ', s);
- WriteLn(ToStr(b[High(b)]));
- WriteLn(ToStr(Length(b)));
- if (ToStr(a) = ToStr(b)) then
- WriteLn('MATCH!');
- SetLength(a, 0);
- SetLength(b, 0);
- end.
Advertisement
Add Comment
Please, Sign In to add comment