Jump to content
Janilabo

TSAInsert

Recommended Posts

Inserts value (x) to TSA by index. Example included.

 

TSAInsert

[scar]procedure TSAInsert(var TSA: array of string; index: Integer; str: string);

var

i, l: Integer;

begin

l := Length(TSA);

SetLength(TSA, (l + 1));

if (index < 0) then

index := 0;

if (index > l) then

index := l;

if (l > index) then

for i := (l - 1) downto index do

TSA[(i + 1)] := TSA;

TSA[index] := str;

end;

 

var

h, i: Integer;

TSA: array of string;

 

begin

ClearDebug;

for i := 0 to 10 do

TSAInsert(TSA, Random(10 + 1), 'i = ' + IntToStr(i));

h := High(TSA);

for i := 0 to h do

WriteLn('TSA[' + IntToStr(i) + ']: ' + TSA);

SetLength(TSA, 0);

end.[/scar]

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



×
  • Create New...