[fpc-devel] Re: Testing for..in feature

Paul Ishenin webpirat at mail.ru
Wed Nov 4 15:45:10 CET 2009


Paul Ishenin wrote:
> Marco van de Voort wrote:
>> Do you have unit tests for multidimensional arrays. I saw quite funky
>> examples (involving dummy variables) in the D2009 help for that.
>>   
> No. I know delphi allows to enumerate multidimensional arrays but fpc 
> traverses only the first dimension.
To be more precise:

{$apptype console}
type
  TSingleDimArray = array[0..1] of integer;
  TMultyDimArray = array[0..1] of TSingleDimArray;
var
  MultyDimArray: TMultyDimArray;
  a: TSingleDimArray;
  i: integer;
begin
  MultyDimArray[0,0]:=1;
  MultyDimArray[0,1]:=2;
  MultyDimArray[1,0]:=3;
  MultyDimArray[1,1]:=4;
  for a in MultyDimArray do
    for i in a do
      WriteLn(i);

  for i in MultyDimArray do
    Writeln(i);
end.

The example compiles and works fine in Delphi. In fpc the second for-in 
loop gives an error. I will try to solve this later.

Best regards,
Paul Ishenin.



More information about the fpc-devel mailing list