Smart pascal source code
var a := [1, 2, 3];
for var i in a do
WriteLn(i);
var ad: array of String;
ad.Add('one', 'two');
for var i in ad do
WriteLn(i);
procedure WriteLnThem(const oa: array of const);
begin
WriteLn(oa.Length);
for var i in oa do
WriteLn(i);
end;
WriteLnThem([]);
WriteLnThem(['alpha', 2, False, 'four']);
{<<< RESULT - CONSOLE LOG >>>
-----------------------------
1
2
3
one
two
0
4
alpha
2
False
four
-----------------------------
{<<<<<<<<< THE END >>>>>>>>>}
var TObject={
$ClassName: "TObject",
$Parent: null,
ClassName: function (s) { return s.$ClassName },
ClassType: function (s) { return s },
ClassParent: function (s) { return s.$Parent },
$Init: function () {},
Create: function (s) { return s },
Destroy: function (s) { for (var prop in s) if (s.hasOwnProperty(prop)) delete s.prop },
Destroy$: function(s) { return s.ClassType.Destroy(s) },
Free: function (s) { if (s!==null) s.ClassType.Destroy(s) }
}
var Exception={
$ClassName: "Exception",
$Parent: TObject,
$Init: function () { FMessage="" },
Create: function (s,Msg) { s.FMessage=Msg; return s }
}
function $New(c) { var i={ClassType:c}; c.$Init(i); return i }
function $Idx(i,l,h,z) {
if (ih) throw Exception.Create($New(Exception),"Upper bound exceeded! Index "+i.toString()+z);
return i-l;
}
function $DIdxR(a,i,z) {
if (i<0) throw Exception.Create($New(Exception),"Lower bound exceeded! Index "+i.toString()+z);
if (i>a.length) throw Exception.Create($New(Exception),"Upper bound exceeded! Index "+i.toString()+z);
return a[i];
}
function WriteLn(value) {
if (window.console) { window.console.log(value); } };
function WriteLnThem(oa) {
var a$1 = 0;
var i;
WriteLn(oa.length);
var $temp1;
for(a$1=0,$temp1=oa.length;a$1<$temp1;a$1++) {
i = $DIdxR(oa,a$1,"");
WriteLn(i);
}
};
var a = [0,0,0],
a$2 = 0;
var i$1 = 0,
ad = [],
a$3 = 0;
var i$2 = "";
/* <<< main JS >>> */
a = [1, 2, 3];
for (a$2 = 0; a$2 <= 2; a$2++) {
i$1 = a[$Idx(a$2, 0, 2, "")];
WriteLn(i$1);
}
ad.push("one", "two");
var $temp2;
for (a$3 = 0, $temp2 = ad.length; a$3 < $temp2; a$3++) {
i$2 = $DIdxR(ad, a$3, "");
WriteLn(i$2);
}
WriteLnThem([]);
WriteLnThem(["alpha", 2, false, "four"]);