Pas2JS pascal source code
type
TMyRec = record
V: Integer;
N: String;
end;
type
TMyRecs = array of TMyRec;
procedure WriteLnRecs(recs: TMyRecs);
var
i: Integer;
begin
WriteLn(recs.Length());
for i := recs.Low() to recs.High() do
WriteLn(IntToStr(recs[i].V) + ': ' + recs[i].N);
end;
procedure AddRec(recs: array of TMyRec; V: Integer; N: String);
var
k: Integer;
begin
k := recs.Length;
recs.SetLength(k + 1);
recs[k].V := V;
recs[k].N := N;
end;
{ main.pas }
Begin
var recs := new TMyRec[0];
WriteLnRecs(recs);
AddRec(recs, 2, 'one');
WriteLnRecs(recs);
AddRec(recs, 2, 'two');
recs.SetLength(3);
WriteLnRecs(recs);
recs.SetLength(1);
WriteLnRecs(recs);
const
cRec: TMyRec = (V: 123; N: 'bye');
recs[0] := cRec;
recs[0].N := 'BYE';
recs.Add(cRec);
WriteLnRecs(recs);
recs.Delete(0);
WriteLnRecs(recs);
{ <<< CONSOLE OUTPUTS >>>
0
1
2: one
3
2: one
2: two
0:
1
2: one
2
123: BYE
123: bye
1
123: bye
}
end;