Pas2JS pascal source code
var az : array[0..4] of Integer;
a : array[5..9] of Integer;
procedure ONE();
var
i: Integer;
begin
Writeln('zero-based array');
for i := Low(az) to High(az) do
begin
az[i] := i;
Writeln(IntToStr(i));
end;
try
i := -1;
az[i] := 0;
except
on e:
Exception do
Writeln(e.Message);
end;
try
i := 5;
az[i] := 0;
except
on e:
Exception do
Writeln(e.Message);
end;
end;
procedure TWO()
var
i: Integer;
begin
Writeln('five-based array');
for i := Low(a) to High(a) do
begin
a[i] := i;
Writeln(IntToStr(i));
end;
try
i := 0;
a[i] := 0;
except
on e:
Exception do
Writeln(e.Message);
end;
try
i := 10;
az[i] := 0;
except
on e:
Exception do
Writeln(e.Message);
end;
end;
begin
One; // zero-based array
// 0,1,2,3,4
WriteLn('---------------');
Two; // five-based array
// 5,6,7,8,9
var az = [0,0,0,0,0],
a = [0,0,0,0,0];
function TWO() {
var i = 0;
WriteLn("five-based array");
for(i=5;i<=9;i++) {
a[(i)-5] = i;
WriteLn(i.toString());
}
try {
i = 0;
a[(i)-5] = 0;
} catch ($e) {
var e = $W($e);
WriteLn(e.FMessage) }
try {
i = 10;
az[i] = 0;
} catch ($e) {
var e$1 = $W($e);
WriteLn(e$1.FMessage) }
};
function ONE() {
var i$1 = 0;
WriteLn("zero-based array");
for(i$1=0;i$1<=4;i$1++) {
az[i$1] = i$1;
WriteLn(i$1.toString());
}
try {
i$1 = -1;
az[i$1] = 0;
} catch ($e) {
var e$2 = $W($e);
WriteLn(e$2.FMessage) }
try {
i$1 = 5;
az[i$1] = 0;
} catch ($e) {
var e$3 = $W($e);
WriteLn(e$3.FMessage) }
};
ONE();
WriteLn("-----");
TWO();