Code:
program _;
function ArrayFromINI(const Section, Keyname, Filename: string; const Max: integer): TVariantArray;
var
I: integer;
T: string;
begin
I := 0;
while True do
begin
T := ReadINI(Section, KeyName + IntToStr(I), FileName);
if (T <> '') then
begin
SetLength(Result, I + 1);
Result[I] := T;
end else
Break;
Inc(I);
if ((I > Max) and (Max > 0)) then
Break;
end;
end;
procedure ArrayToINI(const Arr: TVariantArray; const Section, KeyName, Filename: string);
var
I, H: integer;
begin
H := High(Arr);
for I := 0 to H do
WriteINI(Section, KeyName + IntToStr(I), ToStr(Arr[I]), Filename);
end;
begin
ArrayToINI(['test'], 'Test', 'Wha', ScriptPath + 'data.ini');
WriteLn(ArrayFromINI('Test', 'Wha', ScriptPath + 'data.ini', -1));
end.