> I'd like to include my UnitR into the "uses" of any of my projects, > and not have a fixed array size in R's code that I'd have to change to > match whatever the calling routine is sending. > > It seems I should pass the array to R using a pointer to the > calling routine's array and an integer parameter indicating the number > of elements in the array. My question(s): > > 1. Is this the correct approach? And if so...
No, it isn't. Use either a dynamic arrays everywhere or use static arrays as you currently do, or both and use an open array in the routine R. Below is an example of such code where function R act on two differently dimensionned static arrays and one dynamic array. const Array1 : array [1..4] of Extended = (10, 100, 1000, 10000); // Static array Array2 : array [0..1] of Extended = (4567.9, 987.0); // Static array procedure TForm8.Button1Click(Sender: TObject); var Array3 : array of Extended; // Dynamic array N1, N2, N3 : Integer; begin N1 := R(Array1); N2 := R(Array2); SetLength(Array3, 3); Array3[1] := 123.4; Array3[2] := 1234.67; Array3[3] := -78.8; N3 := R(Array3); Memo1.Lines.Add(Format('%d %d %d', [N1, N2, N3])); end; function TForm8.R(Arg: array of Extended): Integer; var I : Integer; begin Result := 0; for I := Low(Arg) to high(Arg) do begin if Arg[I] >= 1000 then Inc(Result); end; end; Hope this helps. Contribute to the SSL Effort. Visit http://www.overbyte.be/eng/ssl.html -- [EMAIL PROTECTED] The author of the freeware multi-tier middleware MidWare The author of the freeware Internet Component Suite (ICS) http://www.overbyte.be _______________________________________________ Delphi mailing list -> Delphi@elists.org http://www.elists.org/mailman/listinfo/delphi