<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">


<META content="MSHTML 6.00.2900.2180" name=GENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=#ffffff>
<DIV><SPAN class=318214602-07122004><FONT face=Arial color=#0000ff size=2>What 
you have posted there won't compile.</FONT></SPAN></DIV>
<DIV><SPAN class=318214602-07122004><FONT face=Arial color=#0000ff 
size=2></FONT></SPAN>&nbsp;</DIV>
<DIV><SPAN class=318214602-07122004><FONT face=Arial color=#0000ff size=2>For 
starters you can't return an Array of Integer from a function you must make a 
new type that is array of integer and return that.</FONT></SPAN></DIV>
<DIV><SPAN class=318214602-07122004><FONT face=Arial color=#0000ff 
size=2></FONT></SPAN>&nbsp;</DIV>
<DIV><SPAN class=318214602-07122004><FONT face=Arial color=#0000ff 
size=2>ie.</FONT></SPAN></DIV>
<DIV><SPAN class=318214602-07122004><FONT face=Arial color=#0000ff 
size=2>type</FONT></SPAN></DIV>
<DIV><SPAN class=318214602-07122004><FONT face=Arial color=#0000ff size=2>&nbsp; 
ArrayOfInt = array of Integer;</FONT></SPAN></DIV>
<DIV><SPAN class=318214602-07122004><FONT face=Arial color=#0000ff 
size=2></FONT></SPAN>&nbsp;</DIV>
<DIV><SPAN class=318214602-07122004><FONT face=Arial color=#0000ff 
size=2>function GetMyInts: ArrayOfInt;</FONT></SPAN></DIV>
<DIV><SPAN class=318214602-07122004><FONT face=Arial color=#0000ff 
size=2></FONT></SPAN>&nbsp;</DIV>
<DIV><SPAN class=318214602-07122004><FONT face=Arial color=#0000ff size=2>Now as 
you have a dynamic array, you need to set the size.</FONT></SPAN></DIV>
<DIV><SPAN class=318214602-07122004><FONT face=Arial color=#0000ff 
size=2>Therefore you need</FONT></SPAN></DIV>
<DIV><SPAN class=318214602-07122004><FONT face=Arial color=#0000ff 
size=2></FONT></SPAN>&nbsp;</DIV>
<DIV><SPAN class=318214602-07122004><FONT face=Arial color=#0000ff 
size=2>SetLength(result, 11); </FONT></SPAN></DIV>
<DIV><SPAN class=318214602-07122004><FONT face=Arial color=#0000ff 
size=2></FONT></SPAN>&nbsp;</DIV>
<DIV><SPAN class=318214602-07122004><FONT face=Arial color=#0000ff size=2>then 
your for loop would be</FONT></SPAN></DIV>
<DIV><SPAN class=318214602-07122004><FONT face=Arial color=#0000ff 
size=2></FONT></SPAN>&nbsp;</DIV>
<DIV><SPAN class=318214602-07122004><FONT face=Arial color=#0000ff size=2>for i 
:= 0 to 10 do</FONT></SPAN></DIV>
<DIV><SPAN class=318214602-07122004><FONT face=Arial color=#0000ff size=2>&nbsp; 
result[i] := i;</FONT></SPAN></DIV>
<DIV><SPAN class=318214602-07122004><FONT face=Arial color=#0000ff 
size=2></FONT></SPAN>&nbsp;</DIV>
<DIV><SPAN class=318214602-07122004><FONT face=Arial color=#0000ff size=2>then 
in a button event you could have something like</FONT></SPAN></DIV>
<DIV><SPAN class=318214602-07122004><FONT face=Arial color=#0000ff 
size=2></FONT></SPAN>&nbsp;</DIV>
<DIV><SPAN class=318214602-07122004><FONT face=Arial color=#0000ff 
size=2>var<BR>&nbsp; lIntArray: ArrayOnInt;<BR>&nbsp; i: 
Integer;<BR>begin<BR>&nbsp; lIntArray := GetMyInts;<BR>&nbsp; for i := 0 to 
High(lIntArray) do<BR>&nbsp;&nbsp;&nbsp; 
Listbox1.Items.Add(IntToStr(lIntArray[i])); // put items in a 
listbox<BR>end;</FONT></SPAN></DIV>
<DIV><SPAN class=318214602-07122004><FONT face=Arial color=#0000ff 
size=2></FONT></SPAN>&nbsp;</DIV>
<DIV><SPAN class=318214602-07122004><FONT face=Arial color=#0000ff 
size=2>Alternatively you could pass your array variable as a VAR 
parameter.</FONT></SPAN></DIV>
<DIV><SPAN class=318214602-07122004><FONT face=Arial color=#0000ff size=2>Below 
is some code to demostrate a function and procedure that can be 
updated.</FONT></SPAN></DIV>
<DIV><SPAN class=318214602-07122004><FONT face=Arial color=#0000ff size=2>(Need 
a Button and ListBox on a form)</FONT></SPAN></DIV>
<DIV><SPAN class=318214602-07122004><FONT face=Arial color=#0000ff 
size=2></FONT></SPAN>&nbsp;</DIV>
<DIV><SPAN class=318214602-07122004><FONT face=Arial color=#0000ff 
size=2>type<BR>&nbsp; ArrayOnInt = array of Integer;</FONT></SPAN></DIV>
<DIV><FONT face=Arial color=#0000ff size=2></FONT>&nbsp;</DIV>
<DIV><SPAN class=318214602-07122004><FONT face=Arial color=#0000ff 
size=2>function GetMyInts: ArrayOnInt; overload;<BR>var<BR>&nbsp; I: 
Integer;<BR>begin<BR>&nbsp; SetLength(result, 11);<BR>&nbsp; for i := 0 to 10 
do<BR>&nbsp;&nbsp;&nbsp; result[i] := i;<BR>end;</FONT></SPAN></DIV>
<DIV><FONT face=Arial color=#0000ff size=2></FONT>&nbsp;</DIV>
<DIV><SPAN class=318214602-07122004><FONT face=Arial color=#0000ff 
size=2>procedure GetMyInts(var aArray: ArrayOnInt); overload;<BR>var<BR>&nbsp; 
I: Integer;<BR>begin<BR>&nbsp; SetLength(aArray, 11);<BR>&nbsp; for i := 0 to 10 
do<BR>&nbsp;&nbsp;&nbsp; aArray[i] := i;<BR>end;</FONT></SPAN></DIV>
<DIV><FONT face=Arial color=#0000ff size=2></FONT>&nbsp;</DIV>
<DIV><SPAN class=318214602-07122004><FONT face=Arial color=#0000ff 
size=2>procedure TForm3.Button1Click(Sender: TObject);<BR>var<BR>&nbsp; 
lIntArray: ArrayOnInt;<BR>&nbsp; i: Integer;<BR>begin<BR>&nbsp; //lIntArray := 
GetMyInts;<BR>&nbsp; GetMyInts(lIntArray);<BR>&nbsp; for i := 0 to 
High(lIntArray) do<BR>&nbsp;&nbsp;&nbsp; 
Listbox1.Items.Add(IntToStr(lIntArray[i]));<BR>end;<BR></FONT></SPAN></DIV>
<DIV><SPAN class=318214602-07122004><FONT face=Arial color=#0000ff 
size=2>HTH,</FONT></SPAN></DIV>
<DIV><SPAN class=318214602-07122004><FONT face=Arial color=#0000ff 
size=2></FONT></SPAN>&nbsp;</DIV>
<DIV><SPAN class=318214602-07122004><FONT face=Arial color=#0000ff 
size=2>JED</DIV></FONT></SPAN>
<DIV><SPAN class=318214602-07122004><FONT face=Arial color=#0000ff 
size=2></FONT></SPAN>&nbsp;</DIV>
<BLOCKQUOTE dir=ltr style="MARGIN-RIGHT: 0px">
  <DIV class=OutlookMessageHeader dir=ltr align=left><FONT face=Tahoma 
  size=2>-----Original Message-----<BR><B>From:</B> Paul McKenzie 
  [mailto:paul@smss.org.nz]<BR><B>Sent:</B> 7 December 2004 1:20 
  PM<BR><B>To:</B> Delphi List - Delphi<BR><B>Subject:</B> [DUG] Returning Open 
  Arrays<BR><BR></FONT></DIV>
  <DIV><FONT face=Arial size=2>How do I Build and Return an Open 
  Array</FONT></DIV>
  <DIV><FONT face=Arial size=2>I know I can do this with a TList or other means 
  - but seems over the top...</FONT></DIV>
  <DIV>&nbsp;</DIV>
  <DIV><FONT face=Arial size=2>eg</FONT></DIV>
  <DIV><FONT face=Arial size=2>function GetMyInts: Array of 
Integer;</FONT></DIV>
  <DIV><FONT face=Arial size=2>var</FONT></DIV>
  <DIV><FONT face=Arial size=2>&nbsp;&nbsp;&nbsp; I: Integer;</FONT></DIV>
  <DIV><FONT face=Arial size=2>begin</FONT></DIV>
  <DIV><FONT face=Arial size=2>&nbsp;&nbsp;&nbsp; for I := 0 to 10 
  do</FONT></DIV>
  <DIV><FONT face=Arial size=2>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; Result := 
  Result + I;</FONT></DIV>
  <DIV><FONT face=Arial size=2>end;<BR></DIV></FONT>
  <DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV>
  <DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV>
  <DIV><FONT face=Arial size=2>Regards<BR>Paul McKenzie<BR>SMSS 
  Ltd.<BR>Wellington<BR>New Zealand</FONT></DIV></BLOCKQUOTE></BODY></HTML>