Look at this:
Simba Code:
program new;
var
TVA, TVA1, TVA2 : TVariantArray;
procedure SplitArr(Arr : TVariantArray; out Res1, Res2 : TVariantArray);
var
h, i : integer;
begin
h := High(Arr);
for 0 := 1 to h do
begin
if i mod 2 = 0 then
begin
SetArrayLength(Res1, GetArrayLength(Res1) + 1);
Res1[high(Res1)] := Arr[i];
end else
begin
SetArrayLength(Res2, GetArrayLength(Res2) + 1);
Res2[high(Res2)] := Arr[i];
end;
end;
end;
begin
TVA := [5, 4, 'three', 'two', true];
SplitArr(TVA, TVA1, TVA2);
Writeln('Set 1: ' + ToStr(TVA1));
Writeln('Set 2: ' + ToSTr(TVA2));
end.
If you skip the first entry you're going to have to switch the arrays because the 1 is odd.
Edit: ^ like this:
Simba Code:
program new;
var
TVA, TVA1, TVA2 : TVariantArray;
procedure SplitArr(Arr : TVariantArray; out Res1, Res2 : TVariantArray);
var
h, i : integer;
begin
h := High(Arr);
for i := 1 to h do
begin
if i mod 2 = 0 then
begin
SetArrayLength(Res2, GetArrayLength(Res2) + 1);
Res2[high(Res2)] := Arr[i];
end else
begin
SetArrayLength(Res1, GetArrayLength(Res1) + 1);
Res1[high(Res1)] := Arr[i];
end;
end;
end;
begin
TVA := [5, 4, 'three', 'two', true];
SplitArr(TVA, TVA1, TVA2);
Writeln('Set 1: ' + ToStr(TVA1));
Writeln('Set 2: ' + ToSTr(TVA2));
end.