The arguments are passed by value and by reference
Difference between two procedure
AKJo commented: A very simple, but still enlightning example +2
{Difference between two procedure}
Program Difference;
Uses Crt;
{we have two variables,this will A and B}
Var A,B:Byte;
{By value }
Procedure First(F1,F2:Byte);
Begin
F1:=F1+2;
F2:=F2+2;
End;{first}
{By reference} {*}
Procedure Second(Var S1,S2:Byte);
Begin
S1:=S1+2;
S2:=S2+2;
End;{second}
Begin {main}
A:=1;
B:=1;
WriteLn('A:=',A);
WriteLn('B:=',B);
First(A,B);
WriteLn('After the -First- procedure,the result is: ',A+B);
{now,call the 'Second'}
Second(A,B);
WriteLn('And after the -Second- procedure the result is: ',A+B);
ReadKey;
End. {main}
{Note that the 'First' procedure won't change the value of 'A' and 'B'}
{they only changed inside the First procedure,and effectless for the}
{global variables of the main program}
{Created By FlamingClaw 2009.03.10}
est69dog 0 Newbie Poster
FlamingClaw 98 Posting Pro
CMPITG 0 Newbie Poster
est69dog 0 Newbie Poster
mahmoud85 0 Newbie Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.