Janilabo

Janilabo | Stuff() [SCAR Divi]

Apr 28th, 2013
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pascal 0.86 KB | None | 0 0
  1. {==============================================================================]  
  2.   Explanation: Returns str stuffed with s.
  3.                iFrom=start position, iCount=count of chars to stuff with.                  
  4. [==============================================================================}
  5. function Stuff(str, s: string; iFrom, iCount: Integer): string;
  6. var
  7.   l: Integer;
  8. begin
  9.   Result := string(str);
  10.   l := Length(Result);
  11.   if (iFrom < 1) then
  12.     iFrom := 1;
  13.   if (iFrom > l) then
  14.     iFrom := l;
  15.   if (iCount > 0) then
  16.   begin
  17.     if (iCount < 1) then
  18.       iCount := 1;
  19.     if (iCount > l) then
  20.       iCount := l;
  21.     Delete(Result, iFrom, iCount);
  22.   end;
  23.   Insert(s, Result, iFrom);
  24. end;
  25.  
  26. var
  27.   str: string;
  28.  
  29. begin
  30.   ClearDebug;
  31.   str := 'Stuff test to see this is working..!';
  32.   WriteLn(Stuff(str, '() WORKS', 6, 30));
  33. end.
Advertisement
Add Comment
Please, Sign In to add comment