---- Borland's Delphi Discussion List <delphi@elists.org> wrote: > > Hi, > > I am writing a routine to manipulate an array of type extended. > Various other routines will call this routine, and the size of the > array to be passed will vary. > How can I pass an array to this routine? Something like, pass the > size of the array and the location of the first value, so the > routine's calling sequence would be something like (var N : integer; > var Arr : ???). > I want to be able to call it with, for example, an array defined in > the calling program as "var Arr1 : array[1..100] of extended" and also > later with an array defined as "var Arr2: array[1..750] of extended". > How do I define the routine so that it can accept and work with an > array of any size?
The Delphi dialect of Pascal is actually very smart about passing arrays of varying sizes, all you need to do is to use an "open array parameter" like so: var A: array of Extended Within the routine you can determine the upper and lower indicies of the passed array using the System High() and Low() routines. As a brain-dead but mildly useful example, the following will take an arbitrary array of Extended and set each element to a passed in value (good for clearing the array): procedure BumpExtended(var A: array of Extended; V: Extended); var i: Integer; begin for i := Low(A) to High(A) do A[i] := V; end; HTH Stephen Posey [EMAIL PROTECTED] _______________________________________________ Delphi mailing list -> Delphi@elists.org http://www.elists.org/mailman/listinfo/delphi