Array syntax- centrally set multiple array sizes? (solved most rapidly)

Started by Sparky, Tue 10/04/2007 22:24:19

Previous topic - Next topic

Sparky

Hello all. There's a room script that creates several arrays of the same size.
Code: ags
int array_1[1000];
int array_2[1000];
int array_3[1000];


Is there a way to define the array size only once? The compiler doesn't seem to like the following
Code: ags
int limit = 1000;
int array_1[limit];
int array_2[limit];
int array_3[limit];

The error given is "Array size must be constant value.".

Scorpiorus

Yep, it wants a constant value.

Using #define should do the trick:

Code: ags

#define LIMIT 1000

int array_1[ LIMIT ];
int array_2[ LIMIT ];
int array_3[ LIMIT ];

Sparky

Great, that's exactly what I was hoping was possible. Thanks a lot.

SMF spam blocked by CleanTalk