Update:
For some strange reason, the array2_get script worked for both 1D and 2D arrays if argument1 was empty. So I did that instead, since it worked out better and the script got shorter.
It will now return -1 whether the array exists or not.
Script: sizeof(string arrayname, int index)
New! v1.1
/************* sizeof() *************\
Check one and two dimensional arrays
argument0 = array name
argument1 = 2D array index
Note: If 1D array, leave arg1 empty
\************************************/
__check = -1;
if (variable_local_array2_get(argument0,argument1,__check+1))
{
__check=0;
while (variable_local_array2_get(argument0,argument1,__check))
{
__check += 1;
}
}
return __check;Old! v1.0
var __check;
__check = 0;
argument1=-1;
if (argument1<0) //If argument1 is less than 0, check 1 dim array
{
while (variable_local_array_get(argument0,__check))
{
__check += 1;
}
}
else //Check 2 dim array
{
while (variable_local_array2_get(argument0,argument1,__check))
{
__check += 1;
}
}
return __check;How to use:
If you want to check a single dimensional array, just leave the second argument empty.
my_array[0]=1;
my_array[1]=1;
my_array[2]=1;
sizeof("my_array"); //Returns 3If you want to check a 2 dimensional array, you have to put the first index of the array in the second argument.
my_array[0,0]=1;
my_array[0,1]=1;
my_array[0,2]=1;
sizeof("my_array",0); //Returns 3I've search the forum and couldn't find anything like this that found the size of gm arrays, so I hope this can be of some use.
Edited by Wireless, 17 December 2009 - 07:50 PM.











