Routine name(... Out OutputVarName : type; ...)
Description
The Out directive identifies a function or procedure parameter as being a variable reference for outputting to only.
It allows a routine to return data to a variable of caller in addition to the Result value available in functions.
It is equivalent to Var except that the value should not be changed by the routine.
Delphi does not seem to enforce this, nor does it seem to enforce the need to assign a value.
Related commands
Const Starts the definition of fixed data values
Function Defines a subroutine that returns a value
Procedure Defines a subroutine that does not return a value
Var Starts the definition of a section of data variables
Example code : Demonstrate all three types of parameter handling
var
number1, number2, number3 : Integer;
begin
// Put values in our numbers
number1 := 3;
number2 := 4;
number3 := 5;
// Call the simple routine to see how they are handled
ThreeParms(number1, number2, number3);
// Show their values now
ShowMessageFmt('number1 = %d number2 = %d number3 = %d ',
[number1, number2, number3]);
end;
// Simple routine illustrating 3 types of parameter handling
// value1 : Input value only
// value2 : Output value only
// value3 : Input and output value
procedure TForm1.ThreeParms( value1: Integer;
Out value2: Integer;
var value3: Integer);
begin
// Add value1 to value 3 as the value2 output
value2 := value1 + value3;
// Multiply value1 by value3 to give value3 output
value3 := value1 * value3;
end;
Show full unit code
value1 = 3 value2 = 8 value3 = 15