Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Simple Array Question

Status
Not open for further replies.

Stretchwickster

Programmer
Apr 30, 2001
1,746
GB
I understand that it is possible to pass both static array and open array parameters to a procedure in Delphi 6 but is there a way of combining the two? For example, I would like to say something like:

procedure MyProcedure(MyArgs: array[2..n] of integer);

Basically what i'm asking is this: can i have a minimum of 2 and a maximum that is open-ended?

Your help would be much appreciated!
:)
 
array of integer => 1st index 0 , last is size-1

var
A, B: array of Integer;
begin
SetLength(A, 1);
A[0] := 1;
B := A;
B[0] := 2;
end;

procedure MyProcedure(MyArgs: array of integer; n : integer);


PS: array[2..5] of integer signifies an array with the 1st index "2" and the last "5"

PS2: check delphi help 1st (look at the exemples)
 
The short answer is 'no', but why would you want to do that?
 
The reason for doing this is to create an "Addition" function which will accept a variable number of arguments, minimum of two.
 
Just perform a check at the beginning of the procedure to ensure that there are at least 2 elements in the array.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top