1. Computing

Have a Delphi Function Return Multiple Results / Values

By December 11, 2012

Follow me on:

in For Beginners :: A return value from a function is defined by the return type. I guess that in most cases you would write a function to return a single value that would be an integer, string, boolean or some other simple type, also return types could be an array, a string list, an instance of a custom object or alike. Note that even if your function returns a string list (a collection of strings) it still returns a single value: one instance of the string list.

Read the full article to learn how to Return Multiple Values From A Delphi Function

Related:

Comments
December 12, 2012 at 1:00 am
(1) Jürgen Krämer says:

Shouldn’t the first function be written as

function PositiveReciprocal(const valueIn: integer; var valueOut: real): boolean;
begin
result := valueIn > 0;

if result then valueOut := 1 / valueIn;
end;

valueOut should be the reciprocal of valueIn, not of its own value at the time of entering the function. And valueIn must be greater than 0 to prevent a division by zero.

December 12, 2012 at 4:33 am
(2) Zarko Gajic says:

@Jürgen : yes you are right, thanks for noticing. I was playing with implementations while writing this – so made it finally “wrong”. Will fix.

Leave a Comment

Line and paragraph breaks are automatic. Some HTML allowed: <a href="" title="">, <b>, <i>, <strike>

©2014 About.com. All rights reserved.