Advertisement
Janilabo

expand

Dec 28th, 2013
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pascal 0.93 KB | None | 0 0
  1. function StrExpand(trgt_pos: Integer; s1, s2, str: string): string;
  2. var
  3.   l, p, start, finish, s1L, s2L: Integer;
  4.   tmp: string;
  5. begin
  6.   Result := '';
  7.   l := Length(str);
  8.   s1L := Length(s1);
  9.   s2L := Length(s2);
  10.   if (((s1L + s2L) <= l) and (s1L > 0) and (s2L > 0) and (trgt_pos <= l) and (trgt_pos > 0)) then
  11.   begin
  12.     p := 0;
  13.     start := 0;
  14.     finish := PosEx(s2, str, trgt_pos);
  15.     if ((finish < 1) or (finish = trgt_pos)) then
  16.       Exit;
  17.     tmp := Copy(str, 1, trgt_pos);
  18.     repeat
  19.       p := PosEx(s1, tmp, (p + 1));
  20.       if (p > 0) then
  21.         start := p;
  22.     until (p <= 0);
  23.     if ((start <> trgt_pos) and (start > 0) and (finish > 0) and (start < finish)) then
  24.       Result := Copy(str, (start + s1L), ((finish - start) - 1));
  25.   end;
  26. end;
  27.  
  28. var
  29.   str: string;
  30.  
  31. begin
  32.   str := 'C:\Simba\Includes\SPS\img\runescape_surface\air_altar_path.png';
  33.   WriteLn(StrExpand((Length(str) - 4), '\', '.png', str));
  34. end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement