In a message dated 97-05-06 14:32:27 EDT, [log in to unmask] (Alexandre
Crozat) writes:
<< Is it possible to initialize a multi-dimensionnal array during its
definition?
For single-dimensional arrays, the answer is yes:
Init : array (0 .. 3) of Integer := (0 => 1, others => 0)
but what about a 2d array which I would like to fill with zeros?
>>
Yes Alexandre, it's quite simple:
Init : array (0..3, 0..3) of integer := (others => (others => 0));
or the long, long way:
Init : array (0..3, 0..3) of integer := (
0 => (0 => 0, 1 => 0, 2 => 0, 3 => 0),
1 => (0 => 0, 1 => 0, 2 => 0, 3 => 0),
2 => (0 => 0, 1 => 0, 2 => 0, 3 => 0),
3 => (0 => 0, 1 => 0, 2 => 0, 3 => 0)
);
or even:
Init : array (0..3, 0..3) of integer :=
((0,0,0,0),(0,0,0,0),(0,0,0,0),(0,0,0,0));
(I appologize if this isn't a good coding style, It gets the point across
though)
OBTW, I would avoid anonymous types for the array indicies, it can lead to
problems!
Have Fun!
Todd Coniam
t c o n i a m at a o l dot c o m
|