Janilabo

Janilabo | TSAInsert() [SCAR Divi]

Apr 27th, 2013
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pascal 0.80 KB | None | 0 0
  1. {==============================================================================]  
  2.   Explanation: Inserts str to index position in TSA.                  
  3. [==============================================================================}
  4. procedure TSAInsert(var TSA: TStrArray; index: Integer; str: string);
  5. var
  6.   i, l: Integer;
  7. begin
  8.   l := Length(TSA);
  9.   SetLength(TSA, (l + 1));
  10.   if (index < 0) then
  11.     index := 0;
  12.   if (index > l) then
  13.     index := l;
  14.   if (l > index) then
  15.     for i := (l - 1) downto index do
  16.       TSA[(i + 1)] := TSA[i];
  17.   TSA[index] := string(str);
  18. end;
  19.  
  20. var
  21.   tmp: TStrArray;
  22.   h, i: Integer;
  23.  
  24. begin
  25.   ClearDebug;
  26.   tmp := ['Test1', 'Test2', 'Test4', 'Test5'];
  27.   TSAInsert(tmp, 2, 'Test3');
  28.   h := High(tmp);
  29.   for i := 0 to h do
  30.     WriteLn(tmp[i]);
  31. end.
Advertisement
Add Comment
Please, Sign In to add comment