comp.lang.ada
 help / color / mirror / Atom feed
* dynamic arrays in a record ?
@ 2003-02-20  4:57 Chris
  2003-02-20  6:28 ` tmoran
  0 siblings, 1 reply; 4+ messages in thread
From: Chris @ 2003-02-20  4:57 UTC (permalink / raw)


Is there any easy way to put a dynamic array in a record?

I plan to create the array elsewhere based on user input, but I would
like a "placeholder" in the record for it...

...or is this craziness altogether?



SNIP------------------------------------

type board_array is array (positive range <>, positive range <>) of
integer range -1..1;

	type board is record
		aboard: board_array; -- this is junk!
		userscore : integer;
		compscore : integer;
     end record;

----------------------------------------



^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: dynamic arrays in a record ?
@ 2003-02-20  6:20 Grein, Christoph
  0 siblings, 0 replies; 4+ messages in thread
From: Grein, Christoph @ 2003-02-20  6:20 UTC (permalink / raw)
  To: comp.lang.ada

> type board_array is array (positive range <>, positive range <>) of
> integer range -1..1;
> 
> 	type board (First, Second: Positive) is record
> 		aboard: board_array (1..First,1..Second);
> 		userscore : integer;
> 		compscore : integer;
>      end record;



^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: dynamic arrays in a record ?
  2003-02-20  4:57 dynamic arrays in a record ? Chris
@ 2003-02-20  6:28 ` tmoran
  2003-02-20 16:44   ` Chris
  0 siblings, 1 reply; 4+ messages in thread
From: tmoran @ 2003-02-20  6:28 UTC (permalink / raw)


> Is there any easy way to put a dynamic array in a record?
Do you mean something like:

procedure testbb is
  subtype board_sizes is integer range 1 .. 10;
  type cells is range -1 .. 1;

  type board_array is array (board_sizes range <>, board_sizes range <>)
  of cells;

  type boarda(ew, ns : board_sizes) is record
    aboard: board_array(1 .. ew, 1 .. ns);
    userscore : integer;
    compscore : integer;
  end record;

  type boardb(ew, ns : board_sizes := 1) is record
    aboard: board_array(1 .. ew, 1 .. ns);
    userscore : integer;
    compscore : integer;
  end record;

  a : boarda(4,5);
  b : boardb(2,3);
  c : boardb;
  east, north : board_sizes;
begin
  east := 1;  -- get these from user
  north := 2;
  c := (ew=>east, ns => north,
        aboard=>(1 .. east=>(1 .. north=> -1)),
        userscore=>7,compscore=>8);
end testbb;



^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: dynamic arrays in a record ?
  2003-02-20  6:28 ` tmoran
@ 2003-02-20 16:44   ` Chris
  0 siblings, 0 replies; 4+ messages in thread
From: Chris @ 2003-02-20 16:44 UTC (permalink / raw)


worked great... thanks guys !



^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2003-02-20 16:44 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-02-20  4:57 dynamic arrays in a record ? Chris
2003-02-20  6:28 ` tmoran
2003-02-20 16:44   ` Chris
  -- strict thread matches above, loose matches on Subject: below --
2003-02-20  6:20 Grein, Christoph

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox