On Tue, 10 Apr 2012 18:08:04 +0200
dhkblas...@zeelandnet.nl wrote:

>   
> 
> I have some issues when assigning a pointer to a pointer variable.
> Consider this: 
> 
>  TVertex = record
>  x: double;
>  y: double;
>  end;
> 
> PVertex = ^TVertex; 
> 
>  TEdge = record
>  v1: PVertex;
>  v2: PVertex;
>  end; 
> 
> 
> I have assigned a value to a vertex variable. In my code I have an
> array of TEdge. When I try to assign a vertex to the edge element in the
> array the x value suddenly is changed to 3e-308 (or something similar).
> I don't understand why, perhaps someone could help me to figure this
> out.The code I'm using to assign the value is shown below. To my
> knowledge assigning a pointer this way is perfectly legal not?
> 
> 
> procedure add_edge(v1, v2: PVertex);
> begin
>  inc(edge_count);
> 
> SetLength(edge_list, edge_count); 
> 
>  edge_list[edge_count - 1].v1 := v1;
> //

Code looks ok. The bug is probably in the code you didn't send. Maybe
your vertices are on the stack?

Mattias

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

Reply via email to