If you are beginner in Pascal, I could make few suggestions...
According to your code, you simply copy data from LBAPAirchive to UpperBoxAP, but if there is no data to copy, old data in UpperBoxAP retain. Is that what you want?
Perhaps you want to make a log, adding all current data in LBAPAirchive to UpperBoxAP?
Anyway, if simply copy to array of strings according your code, the working change in your original code is just this:
/// Item := UpperBoxAP.Items[i];
Item := LBAPAirchive.Items[i];
However, minimalistic fast code instead of dinamically enlarge array all the time is following:
procedure TForm1.LoadUpperArrayLBAPArchive;
var
i : Integer;
begin
if LBAPAirchive.Items.Count = 0 then
exit;
SetLength (UpperBoxAP, LBAPAirchive.Items.Count);
for i := 0 to LBAPAirchive.Items.Count - 1 do
UpperBoxAP[i] := LBAPAirchive.Items[i];
end;
If LBAPAirchive is TListBox component and UpperBoxAP is TStringList instance, then all is quite simple:
// To copy strings
UpperBoxAP.Assign(LBAPAirchive.Items);
// To add strings
UpperBoxAP.AddStrings(LBAPAirchive.Items);
Just declare UpperBoxAP as I have shown already, create it in the part when create form, free it when destroy it and use just these simple methods. And that is it, no hassle with dynamic array of strings.
Arrays are basic data in pascal, but since this is object Pascal, using TStringList classs instance is preferable in your case and compatible for all components using it and as well simple and clear to use.