Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: Sparky on Tue 10/04/2007 22:24:19

Title: Array syntax- centrally set multiple array sizes? (solved most rapidly)
Post by: Sparky on Tue 10/04/2007 22:24:19
Hello all. There's a room script that creates several arrays of the same size.
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 followingint limit = 1000;
int array_1[limit];
int array_2[limit];
int array_3[limit];

The error given is "Array size must be constant value.".
Title: Re: Array syntax- centrally set multiple array sizes?
Post by: Scorpiorus on Tue 10/04/2007 22:33:31
Yep, it wants a constant value.

Using #define should do the trick:


#define LIMIT 1000

int array_1[ LIMIT ];
int array_2[ LIMIT ];
int array_3[ LIMIT ];
Title: Re: Array syntax- centrally set multiple array sizes?
Post by: Sparky on Wed 11/04/2007 01:03:59
Great, that's exactly what I was hoping was possible. Thanks a lot.