Saturday, February 14, 2009


{***Parameter passing can be had in many ways as detailed below***}


//Pass by value{*The pass by value is the simplest as shown below*}


procedure MyProcPassByValue(inInt : integer; inStr : string);
begin
showmessage('passed parameters :' + inttostr(inInt) + ',' + inStr);
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
MyProcPassByValue(1, 'One');
end;



//Pass by ref
{*The pass by reference goes one stuff ahed and returns valuesto the calling function as shown below*}
procedure MyProcPassByReference(var inInt : integer; var inStr : string);
begin
showmessage('passed parameters :' + inttostr(inInt) + ',' + inStr);
inInt := 2;
inStr := 'Two';
end;



procedure TForm1.Button2Click(Sender: TObject);
var myInt : integer; myStr : string;
begin
myInt := 1; myStr := 'One';
MyProcPassByReference(myInt, myStr);
showmessage('returned parameters :' + inttostr(myInt) + ',' + myStr);
end;



//Pass by const
{*The pass by constant can pass values which cannot be changed inside thecalled application. Remove the comments and compiler wouldnot like it.*}
procedure MyProcPassByConst(Const inInt : integer; Const inStr : string);
begin
showmessage('passed parameters :' + inttostr(inInt) + ',' + inStr);
// inInt := 2;
// inStr := 'Two';
end;

procedure TForm1.Button3Click(Sender: TObject);
var myInt : integer; myStr : string;
begin
myInt := 1; myStr := 'One';
MyProcPassByConst(myInt, myStr);
showmessage('returned parameters :' + inttostr(myInt) + ',' + myStr);
end;



//Pass by out
{*The out parameter is used to return values. You can see it's affects in thestring values that are passed.*}
procedure MyProcPassByOut(Out inInt : integer; Out inStr : string);begin showmessage('passed parameters :' + inttostr(inInt) + ',' + inStr); inInt := 2; inStr := 'Two';end;
procedure TForm1.Button4Click(Sender: TObject);var myInt : integer; myStr : string;begin myInt := 5; myStr := 'Five'; MyProcPassByOut(myInt, myStr); showmessage('returned parameters :' + inttostr(myInt) + ',' + myStr);end;

Friday, January 23, 2009

Hello World

Has been ten years since I met Delphi. It wasn't love at first sight but some casual gettogethere which turned into hardcore love later. When I look back flitering with other lovers later, I would like the world that this was the one I really loved because it was from the heart.

Hello everyone. This is from jump to Delphi