How to get array length

Blitz3D Forums/Blitz3D Programming/How to get array length

Shifty Geezer(Posted 2005) [#1]
I want to run a process on every member of an array

For n = 0 to ArraySize(array())
If such and such
do groovey things
Next

I can't find any GetArraySize function though. Is there any? Or can I use a 'If index not out of array bounds' method? Or do I need to add *another* Global constant?!


Beaker(Posted 2005) [#2]
Global constant only I'm afraid.


GitTech(Posted 2005) [#3]
I'm afraid you'll have to use a constant or variable to store the size of the array.


EDIT: Beaker was 11 seconds faster :P


jfk EO-11110(Posted 2005) [#4]
You could use a trick: always store the dimed size in array index zero.


GitTech(Posted 2005) [#5]
Nice trick :)


big10p(Posted 2005) [#6]
You could use a bank instead of an array, which has a corresponding BankSize command.