Re: Open array
- From: Rob Kennedy <me3@xxxxxxxxxxx>
- Date: Tue, 22 Aug 2006 17:18:59 -0500
Fons Rave wrote:
procedure OpenArray;
procedure Xxx(Bbb : array of boolean);
begin
end;
That is a procedure that takes an open array.
type TArrayOfBoolean = array of boolean;
That is a dynamic array.
procedure Yyy(Bbb : TArrayOfBoolean);
begin
end;
That is a procedure that takes a dynamic array.
var B : array of boolean;
That is a dynamic-array variable.
begin
Xxx([True, False, True]); // 1
That passes an open array to a procedure expecting to receive an open array.
B := [True, False, True]; // 2
That assigns a set of Boolean to a dynamic-array variable.
Yyy([True, False, True]); // 3
That passes either a set of Boolean or an open array of Boolean to a procedure expecting a dynamic array.
end;
Delphi doesn't compile lines 2 and 3. All three look comparable. But they aren't. What's the solution to line 2 and 3 ?
Set the length of the dynamic array with SetLength, and then assign a value to each element of the array.
--
Rob
.
- Follow-Ups:
- Re: Open array
- From: Bjørge
- Re: Open array
- References:
- Open array
- From: Fons Rave
- Open array
- Prev by Date: Re: Delphi contract rates worldwide
- Next by Date: Re: Open array
- Previous by thread: Re: Open array
- Next by thread: Re: Open array
- Index(es):
Relevant Pages
|