I trying to convert a file from my unix system to readable txt file.
My first record has fieldnames in it. The file want to convert has 83 fields.
Occasionally a 'record' line has 84 fields. I don't know. There's nothing special on it.
Before I save the found object to objectlist I get the right fieldname and fieldtype with the indexnumber. Because fheader locates 83 objects and not 84 it should headerfield result in nil.
But an error occurs before I can check if headerfield has values.
It shouldn't happen. the problem is also in Delphi.
Why is generics.collections not givving a nil back. Do I have to do another way to check?
Using Lazarus 2.0.10 / FPC 3.2 / Windows 10
procedure Tconversion.SetRecords(aRegel: TStringlist; aMyRecord: TRecord; const aCharcase : smallint);
var recordfield : TMyField;
headerfield : TMyField;
index : integer;
begin
for index := 0 to aRegel.Count - 1 do
begin
recordfield := TMyField.Create;
headerfield := fHeader[index];
if headerfield <> nil then
begin
recordfield.name := headerfield.value;
recordfield.mydatatype := headerfield.mydatatype;
end else
begin
recordfield.name := format('field%d',[index + 1]);
recordfield.mydatatype := 'character';
end;
recordfield.value := trim(aRegel[index]);
aMyRecord.fMyFields.Add(recordfield);
end;
end;