View mode: basic / threaded / horizontal-split · Log in · Help
February 12, 2005
How to create multidimesinal array
public struct Color
{
    byte r,g,b,a;
};
public Color[][] frameBuffer;

attempt to use:

frameBuffer = new Color[height][width];

where width and height some integer variables produces:

alphablend.d(54): Integer constant expression expected instead of height
alphablend.d(54): cannot implicitly convert expression new Color 
[0][](width) of type Color [0][] to Color [][]

Thanks in advance,

Andrew Fedoniouk.
http://terrainformatica.com
February 12, 2005
Re: How to create multidimesinal array
For dynamic arrays, you don't use that syntax but rather:

frameBuffer.length = height;
for (int i = 0; i < height; i++)
	frameBuffer[i].length = width;

-[Unknown]

> public struct Color
> {
>      byte r,g,b,a;
> };
> public Color[][] frameBuffer;
> 
> attempt to use:
> 
> frameBuffer = new Color[height][width];
> 
> where width and height some integer variables produces:
> 
> alphablend.d(54): Integer constant expression expected instead of height
> alphablend.d(54): cannot implicitly convert expression new Color 
> [0][](width) of type Color [0][] to Color [][]
> 
> Thanks in advance,
> 
> Andrew Fedoniouk.
> http://terrainformatica.com
February 12, 2005
Re: How to create multidimesinal array
Or use

#
#  frameBuffer = new Color[height];
#  foreach (inout Color[] row; frameBuffer) {
#    row = new Color[width];
#  }
#

-- Chris S

Unknown W. Brackets wrote:
> For dynamic arrays, you don't use that syntax but rather:
> 
> frameBuffer.length = height;
> for (int i = 0; i < height; i++)
>     frameBuffer[i].length = width;
> 
> -[Unknown]
> 
>> public struct Color
>> {
>>      byte r,g,b,a;
>> };
>> public Color[][] frameBuffer;
>>
>> attempt to use:
>>
>> frameBuffer = new Color[height][width];
>>
>> where width and height some integer variables produces:
>>
>> alphablend.d(54): Integer constant expression expected instead of height
>> alphablend.d(54): cannot implicitly convert expression new Color 
>> [0][](width) of type Color [0][] to Color [][]
>>
>> Thanks in advance,
>>
>> Andrew Fedoniouk.
>> http://terrainformatica.com
February 13, 2005
Re: How to create multidimesinal array
Thanks, Chris,

Little bit "non-symmetric" with static declaration like int[3][3] but works.

Andrew Fedoniouk.


"Chris Sauls" <ibisbasenji@gmail.com> wrote in message 
news:cukjsa$15j1$1@digitaldaemon.com...
> Or use
>
> #
> #  frameBuffer = new Color[height];
> #  foreach (inout Color[] row; frameBuffer) {
> #    row = new Color[width];
> #  }
> #
>
> -- Chris S
>
> Unknown W. Brackets wrote:
>> For dynamic arrays, you don't use that syntax but rather:
>>
>> frameBuffer.length = height;
>> for (int i = 0; i < height; i++)
>>     frameBuffer[i].length = width;
>>
>> -[Unknown]
>>
>>> public struct Color
>>> {
>>>      byte r,g,b,a;
>>> };
>>> public Color[][] frameBuffer;
>>>
>>> attempt to use:
>>>
>>> frameBuffer = new Color[height][width];
>>>
>>> where width and height some integer variables produces:
>>>
>>> alphablend.d(54): Integer constant expression expected instead of height
>>> alphablend.d(54): cannot implicitly convert expression new Color 
>>> [0][](width) of type Color [0][] to Color [][]
>>>
>>> Thanks in advance,
>>>
>>> Andrew Fedoniouk.
>>> http://terrainformatica.com
February 13, 2005
Re: How to create multidimesinal array
Yes it does leave one with an odd aftertaste.  So Walter, I'd like to 
reiterate my wishing for a 'new Type[#][#]...' syntax.  Would it be very 
difficult?

-- Chris S

Andrew Fedoniouk wrote:
> Thanks, Chris,
> 
> Little bit "non-symmetric" with static declaration like int[3][3] but works.
> 
> Andrew Fedoniouk.
Top | Discussion index | About this forum | D home