[fpc-pascal] Partially initializing array of records

ik idokan at gmail.com
Tue Jul 19 19:52:02 CEST 2011


You are talking about dynamic array:

type
      node = record
            foo : array of integer;
            bar : array of integer;
      end

var
     graph : array of node;


SetLength(graph, 5); // Gives you 0..4 elements
SetLength(graph.foo, 10); //Gives you 0..9 elements
...

Ido
On Tue, Jul 19, 2011 at 20:44, Clay Stuart <clay.stuart at gmail.com> wrote:

> Hello Everyone:
>
> I've got an array of records that looks something like this:
>
> type
>       node = record
>             foo : array[1..10] of integer;
>             bar : array[1..10] of integer;
>       end
>
> var
>      graph : array[1..5] of node;
>
> begin...
>
>
> However, the arrays hold different amounts of numbers.  So node[1].foo
> might hold 5 numbers while node[2].foo might hold only 2.
>
> My Question...
> Is there a way to initialize these numbers somehow.  It seems the compiler
> won't allow me to partly fill the arrays.  If I use them, it appears I have
> to use them all the way.
>
> Thank you in advance,
> Clay
>
> _______________________________________________
> fpc-pascal maillist  -  fpc-pascal at lists.freepascal.org
> http://lists.freepascal.org/mailman/listinfo/fpc-pascal
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-pascal/attachments/20110719/143092a6/attachment.html>


More information about the fpc-pascal mailing list