Passing by value copies a variable within the function without changing the value of the external parameter.
Pass-through, you need to write the Var identifier on the parameter, which changes the value of the externally passed-in parameter.
Such as:
The code is as follows:
UnitUnit1;Interfaceuseswinapi.windows, Winapi.messages, System.sysutils, System.variants, system.classes, Vcl.graphics, Vcl.Controls, Vcl.forms, Vcl.dialogs, Vcl.stdctrls;typeTForm1=class(tform) Memo1:tmemo; Button1:tbutton; procedureButton1Click (Sender:tobject); Private {Private Declarations} Public {Public Declarations} End;varForm1:tform1;Implementation{$R *.DFM}functionDublevalue (varAvalue:integer): Integer;beginAvalue:= Avalue *2;End;functionVardublevalue (Avalue:integer): Integer;beginAvalue:= Avalue *2;End;procedureTform1.button1click (sender:tobject);varX:integer; Y:integer;beginX:=Ten; Dublevalue (X); MEMO1.LINES.ADD ('Delivery by Address'+x.tostring); Y:=Ten; Vardublevalue (Y); MEMO1.LINES.ADD ('Pass by Value'+y.tostring);End;End.
Handbook 008: Pass-by-value and on-site delivery