Pas2JS pascal source code
type
TRec = record
Field: Integer
end;
type
TRec2 = record
A : Integer;
B : String;
c : Boolean;
end;
{ unit1.pas }
const
a1: array [0..0] of TRec = [(Field: 1)];
var
a2: array [1..2] of TRec = [(Field: 2), (Field: 3)];
a3: array [0..1] of TRec2 = [
(A: 1; b: "One"; c: True),(A: 2; B: 'two'; c: False)];
begin
Writeln(a1[0].Field); // 1
Writeln(a2[1].Field); // 2
Writeln(a2[2].Field); // 3
{ test II }
for var i in a3 do
begin
WriteLn(i.A); // 1 2
WriteLn(i.B); // one two
WriteLn(i.C); // true false
end;
var a2 = [{Field:0},{Field:0}],
a2 = [{Field:2}, {Field:3}];
var a3 = [{A$1:0,B:"",c:false},{A$1:0,B:"",c:false}],
a3 = [{A$1:1,B:"One",c:true}, {A$1:2,B:"two",c:false}];
var a$1 = 0;
var i = {A$1:0,B:"",c:false};
var a1 = [{Field:1}];
WriteLn({Field:1}.Field);
WriteLn(a2[(1)-1].Field);
WriteLn(a2[(2)-1].Field);
for(a$1=0;a$1<=1;a$1++) {
Copy$TRec2(a3[a$1],i);
WriteLn(i.A$1);
WriteLn(i.B);
WriteLn(i.c);
}
function Copy$TRec2(s,d) {
d.A$1=s.A$1;
d.B=s.B;
d.c=s.c;
return d;
}
function Clone$TRec2($) {
return {
A$1:$.A$1,
B:$.B,
c:$.c
}
}
function Copy$TRec(s,d) {
d.Field=s.Field;
return d;
}
function Clone$TRec($) {
return {
Field:$.Field
}
}