Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2003-04

Re: strange error - compilable code (Luis Del Aguila)

2 messages · 2 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Luis Del Aguila

The FPC 1.06 don't support dynamic array,
Use FPC 1.1 or use pointer.

El compilador FPC 1.06 no soporta arreglos din�micos Es mejor que uses FPC 1.1 o en todo caso usa punteros.

Can you provided a compilable example that we can use for the test suite. Peter

in FPC 1.06 use pointers, example :

type
 PTVertex3D = ^TVertex3D; //add this declarations, for use Pointer
 TVertex3D = record
   x,y,z : single;
  end;
var
//Vertices1,Vertices2 : array of TVertex3D; //change declarations
 Vertices1,Vertices2 : PTVertex3D;
//procedure TranslateArr(xc,yc,zc:single;var Src,Dst:array of
TVertex3D;count:longint); //change declarations
procedure TranslateArr(xc,yc,zc:single;var
Src,Dst:PTVertex3D;count:longint);
var i : longint;
begin
 for i := 0 to count-1 do
  begin
   Dst[i].x := Src[i].x + xc;
   Dst[i].y := Src[i].y + yc;
   Dst[i].z := Src[i].z + zc;
  end;
end;
begin
//SetLength(Vertices1,1); //change declarations
 Getmem(Vertices1,Sizeof(Vertices1));
 Vertices1[0].x := 3;
 Vertices1[0].y := 2;
 Vertices1[0].z := 1;
//SetLength(Vertices2,1); //change declarations
 Getmem(Vertices2,Sizeof(Vertices2));
 TranslateArr(5,3,-2,Vertices1,Vertices2,5);
 readln
end.

If you need use more vertex, then use this :
Getmem(Vertices1,Sizeof(Vertices1)*5) // for five vertex array

Si tu necesitas usar mas vertices en tu arreglo, entonces debes usar getmem de esta manera :

Getmem(Vertices1,Sizeof(Vertices1)*5) // para arreglos de 5 vertices

Unknown author
to Luis Del Aguila

Sure I can do it this way, but it's the "old way" :-) FPC 1.1 obviously tries to compile it my way, but it fails.

LDA> The FPC 1.06 don't support dynamic array,
LDA> Use FPC 1.1 or use pointer.

LDA> El compilador FPC 1.06 no soporta arreglos dinámicos LDA> Es mejor que uses FPC 1.1 o en todo caso usa punteros.

>Can you provided a compilable example that we can use for the test suite. >Peter

LDA> in FPC 1.06 use pointers, example :

LDA> type
LDA>  PTVertex3D = ^TVertex3D; //add this declarations, for use Pointer
LDA>  TVertex3D = record
LDA>    x,y,z : single;
LDA>   end;
LDA> var
LDA> //Vertices1,Vertices2 : array of TVertex3D; //change declarations
LDA>  Vertices1,Vertices2 : PTVertex3D;
LDA> //procedure TranslateArr(xc,yc,zc:single;var Src,Dst:array of
LDA> TVertex3D;count:longint); //change declarations
LDA> procedure TranslateArr(xc,yc,zc:single;var
LDA> Src,Dst:PTVertex3D;count:longint);
LDA> var i : longint;
LDA> begin
LDA>  for i := 0 to count-1 do
LDA>   begin
LDA>    Dst[i].x := Src[i].x + xc;
LDA>    Dst[i].y := Src[i].y + yc;
LDA>    Dst[i].z := Src[i].z + zc;
LDA>   end;
LDA> end;
LDA> begin
LDA> //SetLength(Vertices1,1); //change declarations
LDA>  Getmem(Vertices1,Sizeof(Vertices1));
LDA>  Vertices1[0].x := 3;
LDA>  Vertices1[0].y := 2;
LDA>  Vertices1[0].z := 1;
LDA> //SetLength(Vertices2,1); //change declarations
LDA>  Getmem(Vertices2,Sizeof(Vertices2));
LDA>  TranslateArr(5,3,-2,Vertices1,Vertices2,5);
LDA>  readln
LDA> end.

LDA> If you need use more vertex, then use this :
LDA> Getmem(Vertices1,Sizeof(Vertices1)*5) // for five vertex array

LDA> Si tu necesitas usar mas vertices en tu arreglo, entonces debes usar LDA> getmem de esta manera :

LDA> Getmem(Vertices1,Sizeof(Vertices1)*5) // para arreglos de 5 vertices

LDA> _______________________________________________ LDA> fpc-pascal maillist -
LDA> http://lists.freepascal.org/mailman/listinfo/fpc-pascal

Best regards, vtech