Smart pascal source code
type
TTest = class
FInteger: Integer;
FString: String;
FFloat: Float;
FBoolean: Boolean;
constructor CreateInt(i: Integer = 123);
constructor CreateStr(s: String = 'ABC');
constructor CreateFloat(f: Float = 12.3);
constructor CreateBoolean(b: Boolean = True);
procedure SetInt(i: Integer = 456);
procedure SetStr(s: String = 'DEF');
procedure SetFloat(f: Float = 4.56);
procedure SetBoolean(b: Boolean = True);
procedure WriteLnOut;
end;
constructor TTest.CreateInt(i: Integer = 123);
begin
FInteger := i;
end;
constructor TTest.CreateStr(s: String = 'ABC');
begin
FString := s;
end;
constructor TTest.CreateFloat(f: Float = 12.3);
begin
FFloat := f;
end;
constructor TTest.CreateBoolean(b: Boolean = True);
begin
FBoolean := b;
end;
procedure TTest.SetInt(i: Integer = 456);
begin
FInteger := i;
end;
procedure TTest.SetStr(s: String = 'DEF');
begin
FString := s;
end;
procedure TTest.SetFloat(f: Float = 4.56);
begin
FFloat := f;
end;
procedure TTest.SetBoolean(b: Boolean = True);
begin
FBoolean := b;
end;
procedure TTest.WriteLnOut;
begin
WriteLn(IntToStr(FInteger) + ',' + FString + ',' + FloatToStr(FFloat) + ',' +
BoolToStr(FBoolean));
end;
procedure WriteLnInt(i: Integer = 789);
begin
WriteLn(IntToStr(i));
end;
procedure WriteLnStr(s: String = 'IJK');
begin
WriteLn(s);
end;
procedure WriteLnFloat(f: Float = 78.9);
begin
WriteLn(FloatToStr(f));
end;
procedure WriteLnBoolean(b: Boolean = True);
begin
WriteLn(BoolToStr(b));
end;
{ main.pas }
var
t: TTest;
Begin
TTest.CreateInt(1).WriteLnOut;
TTest.CreateInt.WriteLnOut;
TTest.CreateStr('zzz').WriteLnOut;
TTest.CreateStr.WriteLnOut;
TTest.CreateFloat(3.14).WriteLnOut;
TTest.CreateFloat.WriteLnOut;
TTest.CreateBoolean(False).WriteLnOut;
TTest.CreateBoolean(True).WriteLnOut;
TTest.CreateBoolean.WriteLnOut;
WriteLn('');
WriteLn('---');
WriteLn('');
t := TTest.Create;
t.WriteLnOut;
t.SetInt;
t.WriteLnOut;
t.SetInt(2);
t.WriteLnOut;
t.SetStr;
t.WriteLnOut;
t.SetStr('aaa');
t.WriteLnOut;
t.SetFloat;
t.WriteLnOut;
t.SetFloat(2.5);
t.WriteLnOut;
t.SetBoolean;
t.WriteLnOut;
t.SetBoolean(False);
t.WriteLnOut;
WriteLn('');
WriteLn('---');
WriteLn('');
WriteLnInt;
WriteLnInt(1);
WriteLnStr;
WriteLnStr('bbb');
WriteLnFloat;
WriteLnFloat(1.5);
WriteLnBoolean;
WriteLnBoolean(True);
WriteLnBoolean(False);
{ <<<<<<<<<<<< CONSOLE OUTPUTS >>>>>>>>>>>>>>>>>>>
1,,0,False
123,,0,False
0,zzz,0,False
0,ABC,0,False
0,,3.14,False
0,,12.3,False
0,,0,False
0,,0,True
0,,0,True
---
0,,0,False
456,,0,False
2,,0,False
2,DEF,0,False
2,aaa,0,False
2,aaa,4.56,False
2,aaa,2.5,False
2,aaa,2.5,True
2,aaa,2.5,False
---
789
1
IJK
bbb
78.9
1.5
True
True
False
}
var t = null;
TTest.WriteLnOut(TTest.CreateInt($New(TTest),1));
TTest.WriteLnOut(TTest.CreateInt($New(TTest),123));
TTest.WriteLnOut(TTest.CreateStr($New(TTest),"zzz"));
TTest.WriteLnOut(TTest.CreateStr($New(TTest),"ABC"));
TTest.WriteLnOut(TTest.CreateFloat($New(TTest),3.14));
TTest.WriteLnOut(TTest.CreateFloat($New(TTest),12.3));
TTest.WriteLnOut(TTest.CreateBoolean($New(TTest),false));
TTest.WriteLnOut(TTest.CreateBoolean($New(TTest),true));
TTest.WriteLnOut(TTest.CreateBoolean($New(TTest),true));
WriteLn("");
WriteLn("---");
WriteLn("");
t = TObject.Create($New(TTest));
TTest.WriteLnOut(t);
TTest.SetInt(t,456);
TTest.WriteLnOut(t);
TTest.SetInt(t,2);
TTest.WriteLnOut(t);
TTest.SetStr(t,"DEF");
TTest.WriteLnOut(t);
TTest.SetStr(t,"aaa");
TTest.WriteLnOut(t);
TTest.SetFloat(t,4.56);
TTest.WriteLnOut(t);
TTest.SetFloat(t,2.5);
TTest.WriteLnOut(t);
TTest.SetBoolean(t,true);
TTest.WriteLnOut(t);
TTest.SetBoolean(t,false);
TTest.WriteLnOut(t);
WriteLn("");
WriteLn("---");
WriteLn("");
WriteLnInt(789);
WriteLnInt(1);
WriteLnStr("IJK");
WriteLnStr("bbb");
WriteLnFloat(78.9);
WriteLnFloat(1.5);
WriteLnBoolean(true);
WriteLnBoolean(true);
WriteLnBoolean(false);
function WriteLnBoolean(b) {
WriteLn(BoolToStr(b));
};
function WriteLnFloat(f) {
WriteLn(FloatToStr$_Float_(f));
};
function WriteLnStr(s) {
WriteLn(s);
};
function WriteLnInt(i) {
WriteLn(i.toString());
};
/// TTest = class (TObject)
/// [line: 72, column: 3, file: uMain]
var TTest = {
$ClassName:"TTest",$Parent:TObject
,$Init:function ($) {
TObject.$Init($);
$.FBoolean = false;
$.FFloat = 0;
$.FInteger = 0;
$.FString = "";
}
/// constructor TTest.CreateBoolean(b: Boolean = True)
/// [line: 105, column: 19, file: uMain]
,CreateBoolean:function(Self, b$1) {
Self.FBoolean = b$1;
return Self
}
/// constructor TTest.CreateFloat(f: Float = 12,3)
/// [line: 100, column: 19, file: uMain]
,CreateFloat:function(Self, f$1) {
Self.FFloat = f$1;
return Self
}
/// constructor TTest.CreateInt(i: Integer = 123)
/// [line: 90, column: 19, file: uMain]
,CreateInt:function(Self, i$1) {
Self.FInteger = i$1;
return Self
}
/// constructor TTest.CreateStr(s: String = 'ABC')
/// [line: 95, column: 19, file: uMain]
,CreateStr:function(Self, s$1) {
Self.FString = s$1;
return Self
}
/// procedure TTest.SetBoolean(b: Boolean = True)
/// [line: 125, column: 17, file: uMain]
,SetBoolean:function(Self, b$2) {
Self.FBoolean = b$2;
}
/// procedure TTest.SetFloat(f: Float = 4,56)
/// [line: 120, column: 17, file: uMain]
,SetFloat:function(Self, f$2) {
Self.FFloat = f$2;
}
/// procedure TTest.SetInt(i: Integer = 456)
/// [line: 110, column: 17, file: uMain]
,SetInt:function(Self, i$2) {
Self.FInteger = i$2;
}
/// procedure TTest.SetStr(s: String = 'DEF')
/// [line: 115, column: 17, file: uMain]
,SetStr:function(Self, s$2) {
Self.FString = s$2;
}
/// procedure TTest.WriteLnOut()
/// [line: 130, column: 17, file: uMain]
,WriteLnOut:function(Self) {
WriteLn((Self.FInteger.toString()+","+Self.FString+","+FloatToStr$_Float_(Self.FFloat)+","+BoolToStr(Self.FBoolean)));
}
,Destroy:TObject.Destroy
};