In Delphi it is possible to pass a local copy of a variable when calling a procedure or a function, and it is also possible to pass the actual variable itself.For example the following code passes a local copy of the integer variable 'amount' to a procedure...]
procedure TForm1.PassAnInt;
var amount : integer;
begin
amount := 10;
ChangeInt(amount);
showmessage(IntToStr(amount));
end;procedure TForm1.ChangeInt(amount : integer);
begin
amount := 22;
end;When showmessage executes 'amount' is shown to be equal to 10 (the variable 'amount' in the second procedure was working on a second copy of a variable also named 'amount' which was in scope only while the ChangeInt function was executing. Because amount was passed to the procedure by value the original value of amount remains unchanged. However there are other ways to pass variables which would actually change the orginal variable 'amount'. For example by using the 'var' key word in the procedure definition this indicates to the compiler that the variable is to be passed 'by reference' (rather than 'by value').
procedure TForm1.ChangeInt(var amount : integer);
In this case when the showmessage procedure executes 'amount' now causes the display of the value of 22. The actual variable was changed and no local copy was made, because a reference to the actual variable being passed was sent to the procedure as a pointer to its location in memory. Note that this would work no matter what name was given to the variable in the procedure or function declaration...procedure TForm1.ChangeInt(var anyname : integer);
In this example the anyname would be set to 22, and once again 'amount' would be displayed as having the value 22, since the var statement in the header indicates that a pointer to the original variable is to be created, so that the procedure or function actually changes the original value. This is a feature often used in API functions as a way of returning more than one result from a function (while the function returns a result in the usual way, the inclusion of pointers in the header declaration results in multiple results being returned in these variables as well).
It also makes sense then that another way to alter an original variable or a set of variables is to pass actual pointers to these variables to a function or procedure, and in this case, since the pointer is pointing to the actual memory locations of these variables any changes made to them in another function is going to change the original values. Passing a pointer to a variable is thus the same as using the 'var' keyword in the function header as illustrated above.
procedure TForm1.PassAPointer;
var
amount : integer;
intPtr : ^integer;
begin
amount := 10;
intPtr^ := amount;
ChangeInt(intPtr);
showmessage(IntToStr(amount));
end;procedure TForm1.ChangeInt(apointer : ^integer);
begin
apointer^ := 22;
end;In the above example the procedure ChangeInt acts like a function by 'returning a value' (because it was passed a pointer to the variable amount it actually alters the value of amount when the object pointed to by the pointer is set equal to 22).
Passing by reference (using either a pointer or the var declaration in the header) makes sense if you want to return multiple values from a procedure or function, or when the objects being passed are quite large, such as strings, graphics, or objects (a local copy of these large data structures need not be made which is quicker and also a more efficient use of memory).
There is syntax in C++ that resembles the 'var' statement in Delphi and produces the same result (rather than creating a local copy of a variable being passed the original is used). The ampersand is used in the function or procedure declaration to indicate that the address of the variable is being passed rather the value contained by the variable - in otherwords a reference to the variable is being passed, the equivalent to passing a pointer, which, after all, just contains the address of the variable. In C++ this would look like this...
void ChangeInt(int& amount)
{
amount = 22;
}
The keyword 'void' indicates that this routine returns no value (in otherwords it is a procedure, since functions return a value). The ampersand indicates that the variable 'amount' refers to a variable being passed by reference, so as in the Delphi example above, this variable will actually be set to the value 22.Records (or structures as they are called in C++) can also be passed by reference and in the API this method would be the typical case, since often structures are quite large.
void DoChanges(arecord& MyRecord)
{...all the program code here will alter the fields in 'MyRecord', which was passed by reference and so refers to the actual address of the original record...
}
A Unified Field Theory
![]()
The Unified Field Theory
is also available as a zip file -> unified.zip
Introduction :The Pioneer Effect and the New Physics. A brief description of the new physics required to explain the 'Pioneer Effect', which is the constant deceleration of space craft as they fly through space.

