Smart pascal source code
var s: String;
var o: TObject;
var i: IInterface;
var a: array of Variant;
try
WriteLn(Format('%d', [s]));
except
on E: Exception do
WriteLn(E.Message);
end;
try
WriteLn(Format('%d', [o]));
except
on E: Exception do
WriteLn(E.Message);
end;
try
WriteLn(Format('%d', [i]));
except
on E: Exception do
WriteLn(E.Message);
end;
try
WriteLn(Format('%d', [a]));
except
on E: Exception do
WriteLn(E.Message);
end;
{<<< RESULT - CONSOLE LOG >>>
-----------------------------
Format '%d' invalid or incompatible with argument [line: 7, column: 12]
Format '%d' invalid or incompatible with argument [line: 14, column: 12]
Format '%d' invalid or incompatible with argument [line: 21, column: 12]
Format '%d' invalid or incompatible with argument [line: 28, column: 12]
-----------------------------
{<<<<<<<<< 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 $W(e) { return e.ClassType?e:Exception.Create($New(Exception),e.constructor.name+", "+e.message) }
function $New(c) { var i={ClassType:c}; c.$Init(i); return i }
function $Is(o,c) {
if (o===null) return false;
return $Inh(o.ClassType,c);
}
;
function $Inh(s,c) {
if (s===null) return false;
while ((s)&&(s!==c)) s=s.$Parent;
return (s)?true:false;
}
;
function $Check(i,z) { if (i) return i; throw Exception.Create($New(Exception),"Object not instantiated"+z); }
function WriteLn(value) {
if (window.console) { window.console.log(value); } };
var s = "";
var o = null;
var i = null;
var a = [];
/* <<< main JS >>> */
try {
WriteLn((s.toString()));
} catch ($e) {
var E = $W($e);
WriteLn($Check(E,"").FMessage) }
try {
WriteLn((o.toString()));
} catch ($e) {
var E$1 = $W($e);
WriteLn($Check(E$1,"").FMessage) }
try {
WriteLn((i.toString()));
} catch ($e) {
var E$2 = $W($e);
WriteLn($Check(E$2,"").FMessage) }
try {
WriteLn((a.toString()));
} catch ($e) {
var E$3 = $W($e);
WriteLn($Check(E$3,"").FMessage) }