Smart pascal source code
type
TMyObj = class
Field: String;
procedure Test(a: String);
function GetIt: String;
end;
procedure TMyObj.Test(a: String);
begin
procedure Loc(b: String);
begin
Field := a + b;
end;
Loc(a);
end;
function TMyObj.GetIt: String;
begin
function Loc: String;
begin
Result := Field;
end;
Result := Loc;
end;
var o := TMyObj.Create;
o.Test('hello');
WriteLn(o.Field);
WriteLn(o.GetIt);
{<<< RESULT - CONSOLE LOG >>>
-----------------------------
hellohello
hellohello
-----------------------------
{<<<<<<<<< THE END >>>>>>>>>}
var TMyObj = {
$ClassName:"TMyObj",$Parent:TObject
,$Init:function ($) {
TObject.$Init($);
$.Field = "";
}
,Test:function(Self, a) {
function Loc(b) {
$Check(Self,"").Field = a+b;
};
Loc(a);
}
,GetIt:function(Self) {
var Result = "";
function Loc$1() {
return $Check(Self,"").Field;
};
Result = Loc$1();
return Result
}
,Destroy:TObject.Destroy
};
var o = null;
/* <<< main JS >>> */
o = TObject.Create($New(TMyObj));
TMyObj.Test(o,"hello");
WriteLn($Check(o,"").Field);
WriteLn(TMyObj.GetIt(o));