[fpc-pascal] property of an array

Jeremy Cowgar jeremy at cowgar.com
Sun Jan 4 14:50:34 CET 2009


On Sun, 04 Jan 2009 05:25:40 -0500, Joost van der Sluis <joost at cnoc.nl>  
wrote:

> Op zaterdag 03-01-2009 om 19:04 uur [tijdzone -0500], schreef Jeremy
> Cowgar:
>
>> myObj.ColumnNames := [ 'Id', 'Name', 'Age' ];
>>      Error: Ordinal expression expected
>
> A list of values between square brackets are a set, not an array.
>
> You'll have to do:
>
>   AnArray[0] := 'Id';
>   anArray[1] := 'Name';
>   anArray[2] := 'Age';
>   myObj.ColumnNames := AnArray;
>
> Or create a constant array and use that.
>

My original definition is:

   procedure SetColumnNames(names : StringArray);
   property ColumnNames : StringArray write SetColumnNames;

Why does it work when I call it by the procedure?

myObj.SetColumnNames(['Id', 'Name', 'Age']);

but not:

myObj.ColumnNames := ['Id', 'Name', 'Age'];

Jeremy



More information about the fpc-pascal mailing list