Lazarus

Free Pascal => General => Topic started by: Fred vS on April 09, 2014, 01:53:25 am

Title: Array of array of array problem...
Post by: Fred vS on April 09, 2014, 01:53:25 am
Hello.
I have some trouble with array :

Code: [Select]
type
...
  TDArFloat = array of cfloat;
   TDArPARFloat = array of TDArFloat;
  TDArIARFloat = array of TDArPARFloat; 

....
var
mymultiarray : TDArIARFloat ;
 

When i use that code with fpc 2.7.1 => perfect, no problem :
Code: [Select]
setlength(mymultiarray,1) ;
 setlength(mymultiarray[0], 1) ;
  setlength(mymultiarray[0].[0],1) ;
 

But with fpc 2.6.2 i have that error  message :
Quote
setlength(mymultiarray[0].[0],1)
 Error: Illegal qualifier

What must i do to be fpc 2.6/2.7 compatible ?

Many thanks.

Fred
Title: Re: Array of array of array problem...
Post by: engkin on April 09, 2014, 01:59:38 am
Maybe SetLength(mymultiarray[0, 0], 1);?
Title: Re: Array of array of array problem...
Post by: Fred vS on April 09, 2014, 02:02:45 am
Code: [Select]
SetLength(mymultiarray[0, 0], 1);=>
Quote
Error: Incompatible types: got "Set Of Byte" expected "Int64"
Title: Re: Array of array of array problem...
Post by: engkin on April 09, 2014, 02:17:09 am
From an example from the docs (http://www.freepascal.org/docs-html/ref/refsu18.html#x42-460003.3.1):
SetLength(mymultiarray, 1, 1, 1);
Title: Re: Array of array of array problem...
Post by: Fred vS on April 09, 2014, 04:48:47 am
@ engkin : Many thanks.

Aaargh, lot of code to change and...
 with SetLength(mymultiarray, 1, 1, 1), it set length for each array.
With the fpc 2.7.1 syntax, you can set only the length of last array.

Or maybe does it exist something like : SetLength(mymultiarray, -1, -1, 3) but i do not find it in doc  ;)
Title: Re: Array of array of array problem...
Post by: Martin_fr on April 09, 2014, 05:26:29 am
Code: [Select]
setlength(mymultiarray[0].[0],1)

Why the "." ?

Should it not be
Code: [Select]
setlength(mymultiarray[0][0],1)
Title: Re: Array of array of array problem...
Post by: Fred vS on April 09, 2014, 11:57:47 am
@ Martin_fr => more than ever => brillantissimo  ;)

Code: [Select]
setlength(mymultiarray[0][0],1)
Did the trick  ;D

Many thanks.

(and now re-change all my code  :-X )

PS : Strange that setlength(mymultiarray[0].[0],1) works perfectly with 2.7.1.
Title: Re: Array of array of array problem...
Post by: Martin_fr on April 15, 2014, 04:56:42 pm
http://bugs.freepascal.org/view.php?id=26016
TinyPortal © 2005-2018