BorlandTalk.com Forum Index BorlandTalk.com
Borland discussion newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Function returning record type data or array

 
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi Students
View previous topic :: View next topic  
Author Message
Maaz Rizki
Guest





PostPosted: Wed Jan 24, 2007 8:58 pm    Post subject: Function returning record type data or array Reply with quote



Hi,
I have been using Delphi 7 for a while, I am able figure out quite few
things. But once in a while I hit wall. I want to send data to a function,
two values in array or record type, and do some processing inside the
function using two values, and return array or record type values back.
Since I need two distinct values out back from function I need that function
return record type of array.

I would highly appreciate a help.

Maaz Rizki
mrizki (AT) fairwaymarket (DOT) com
Back to top
Craig Stuntz [TeamB]
Guest





PostPosted: Wed Jan 24, 2007 9:50 pm    Post subject: Re: Function returning record type data or array Reply with quote



Maaz Rizki wrote:

Quote:
Since I need two distinct values out back from function I need that
function return record type of array.

You could do that, but easier would be to use out arguments:

procedure DoSomethingToArray(
const AInput: array of integer;
out AOutput1: array of integer;
out AOutput2: array of integer);
var
iItem: integer;
begin
for iItem := Low(AInput) to High(AInput) do begin
AOutput1 := Pred(AInput[iItem]);
AOutput1 := Succ(AInput[iItem]);
end;
end;

procedure Foo;
var
AI, AO1, AO2: array[0..9] of integer;
iItem: integer;
begin
for iItem := Low(AI) to High(AI) do begin
AI[item] := iItem;
end;
DoSomethingToArray(AI, AO1, AO2);
// now use AO1 and AO2...
end;

--
Craig Stuntz [TeamB] ˇ Vertex Systems Corp. ˇ Columbus, OH
Delphi/InterBase Weblog : http://blogs.teamb.com/craigstuntz
Borland newsgroup denizen Sergio González has a new CD of
Irish music out, and it's good: http://tinyurl.com/7hgfr
Back to top
Display posts from previous:   
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi Students All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.