Nochmals Danke an alle
Bin euren Ratschlägen gefolgt und zu folgendem Ergebnis gekommen
Delphi-Quellcode:
procedure TMap.LoadMap(fileName: string);
var
listFields: TStringList;
i,k,c: integer;
dlgOpenMap: TOpenDialog;
begin
dlgOpenMap := TOpenDialog.Create(nil);
listFields := TStringList.Create;
fileName := fileName + MAP_FILE_EXTENSION;
try
if not FileExists(mapPath + fileName ) then
if dlgOpenMap.Execute then
fileName := ExtractFileName(dlgOpenMap.FileName);
listFields.LoadFromFile(mapPath + fileName);
c := 0;
for i := 0 to High(Playground) do
for k := 0 to High(Playground[i]) do
begin
Playground[i][k].Free;
Playground[i][k] := nil;
Playground[i][k] := TField.Create(
TFieldKinds(StrToInt(listFields.Strings[c][1]))
,i,k);
case TFieldKinds(StrToInt(listFields.Strings[c][1])) of
fkENTRANCE: listEntrances.Add(Playground[i][k]);
fkEXIT: listExits.Add(Playground[i][k]);
end;
if (listFields.Strings[c][2] = '-') then
Playground[i][k].nextField := TNextField(StrToInt('-' +listFields.Strings[c][3]))
else
Playground[i][k].nextField := TNextField(StrToInt(listFields.Strings[c][2]));
inc(c);
end;
finally
listFields.Free;
dlgOpenMap.Free;
end;
Draw(false);
end;