Array of Record Type



Using array of TRec
Pas2JS pascal source code
type TRec = record Field: Integer end; procedure WriteLnArray(a: array of TRec); var i: Integer; begin Writeln(IntToStr(Length(a)) + ':{'); for i := 0 to High(a) do begin if i > 0 then Writeln(','); Writeln(IntToStr(a[i].Field)); end; Writeln('}'); end; { TApplication } procedure TApplication.RunApp; var r: TRec; a: array of TRec; begin a.Add(r); r.Field := 1; a.Add(r); r.Field := -1; a.Insert(0, r); WriteLnArray(a); // 3:{-1,0,1} r.Field := 123; WriteLnArray(a); // 3:{-1,0,1} a.Delete(1); WriteLnArray(a); // 2:{-1,1}